Mock call to os.path.isdir in roll_deps_test.

Bug: b/365524353
Change-Id: I9494a022b18b6c9c240f86a77ec0430cb27149b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362085
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42986}
diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py
index 445b91d..4a9c90c 100755
--- a/tools_webrtc/autoroller/roll_deps.py
+++ b/tools_webrtc/autoroller/roll_deps.py
@@ -189,6 +189,12 @@
     return std_output, err_output
 
 
+def _IsExistingDir(path):
+    """Returns True if `path` exists and is a dir.
+    """
+    return os.path.isdir(path)
+
+
 def _GetBranches():
     """Returns a tuple of active,branches.
 
@@ -620,7 +626,7 @@
         if isinstance(dep, ChangedVersionEntry):
             continue
         local_dep_dir = os.path.join(GCLIENT_ROOT_DIR, dep.path)
-        if not os.path.isdir(local_dep_dir):
+        if not _IsExistingDir(local_dep_dir):
             raise RollError(
                 'Cannot find local directory %s. Either run\n'
                 'gclient sync --deps=all\n'
diff --git a/tools_webrtc/autoroller/unittests/roll_deps_test.py b/tools_webrtc/autoroller/unittests/roll_deps_test.py
index 69f9aeb..fed0238 100755
--- a/tools_webrtc/autoroller/unittests/roll_deps_test.py
+++ b/tools_webrtc/autoroller/unittests/roll_deps_test.py
@@ -85,6 +85,13 @@
         return None, None
 
 
+class MockIsExistingDir:
+    """Pretends that all paths are valid directories."""
+
+    def __call__(self, *args, **kwargs):
+        return True
+
+
 class TestRollChromiumRevision(unittest.TestCase):
 
     def setUp(self):
@@ -134,9 +141,10 @@
 
         changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps)
         with mock.patch('roll_deps._RunCommand', NullCmd()):
-            UpdateDepsFile(self._webrtc_depsfile_android,
-                           NO_CHROMIUM_REVISION_UPDATE, changed_deps,
-                           new_cr_contents)
+            with mock.patch('roll_deps._IsExistingDir', MockIsExistingDir()):
+                UpdateDepsFile(self._webrtc_depsfile_android,
+                               NO_CHROMIUM_REVISION_UPDATE, changed_deps,
+                               new_cr_contents)
 
         with open(self._webrtc_depsfile_android, 'rb') as deps_file:
             updated_contents = deps_file.read().decode('utf-8')