Repository: azavea/raster-vision

Issue:
Unit Tests: `task` Directory



Discussion:

Resolving patch:
diff --git a/rastervision/utils/files.py b/rastervision/utils/files.py
--- a/rastervision/utils/files.py
+++ b/rastervision/utils/files.py
@@ -73,7 +73,8 @@ def sync_from_dir(src_dir_uri, dest_dir_uri, delete=False, fs=None):
     fs.sync_from_dir(src_dir_uri, dest_dir_uri, delete=delete)
 
 
-def start_sync(src_dir_uri, dest_dir_uri, sync_interval=600, fs=None):
+def start_sync(src_dir_uri, dest_dir_uri, sync_interval=600,
+               fs=None):  # pragma: no cover
     """Start syncing a directory on a schedule.
 
     Calls sync_to_dir on a schedule.
@@ -157,7 +158,7 @@ def file_exists(uri, fs=None):
     return fs.file_exists(uri)
 
 
-def list_paths(uri, ext=None, fs=None):
+def list_paths(uri, ext='', fs=None):
     if uri is None:
         return None
 


Test patch:
diff --git a/scripts/unit_tests b/scripts/unit_tests
--- a/scripts/unit_tests
+++ b/scripts/unit_tests
@@ -22,6 +22,6 @@ else
     if ! [ -x "$(command -v coverage)" ]; then
 	python -m unittest discover tests
     else
-	coverage run --source=rastervision '--omit=rastervision/protos/**.py' -m unittest discover tests
+	coverage run -m unittest discover tests
     fi
 fi
diff --git a/tests/utils/test_files.py b/tests/utils/test_files.py
--- a/tests/utils/test_files.py
+++ b/tests/utils/test_files.py
@@ -10,7 +10,7 @@
 from rastervision.utils.files import (
     file_to_str, str_to_file, download_if_needed, upload_or_copy,
     load_json_config, ProtobufParseException, make_dir, get_local_path,
-    file_exists, sync_from_dir, sync_to_dir)
+    file_exists, sync_from_dir, sync_to_dir, list_paths)
 from rastervision.filesystem import (NotReadableError, NotWritableError)
 from rastervision.filesystem.filesystem import FileSystem
 from rastervision.protos.task_pb2 import TaskConfig as TaskConfigMsg
@@ -328,13 +328,12 @@ def test_list_paths_s3(self):
         directory = os.path.dirname(path)
         make_dir(directory, check_empty=False)
 
-        fs = FileSystem.get_file_system(s3_path, 'r')
-
         with open(path, 'w+') as file:
             file.write(self.lorem)
         upload_or_copy(path, s3_path)
 
-        self.assertEqual(len(fs.list_paths(s3_directory)), 1)
+        list_paths(s3_directory)
+        self.assertEqual(len(list_paths(s3_directory)), 1)
 
 
 class TestLocalMisc(unittest.TestCase):
@@ -374,7 +373,7 @@ def test_sync_from_dir_local(self):
         fs.write_bytes(path, bytes([0x00, 0x01]))
         sync_from_dir(src, dst, delete=True)
 
-        self.assertEqual(len(fs.list_paths(dst)), 1)
+        self.assertEqual(len(list_paths(dst)), 1)
 
     def test_sync_from_dir_noop_local(self):
         path = os.path.join(self.temp_dir.name, 'lorem', 'ipsum.txt')
@@ -385,7 +384,7 @@ def test_sync_from_dir_noop_local(self):
         fs.write_bytes(path, bytes([0x00, 0x01]))
         sync_from_dir(src, src, delete=True)
 
-        self.assertEqual(len(fs.list_paths(src)), 1)
+        self.assertEqual(len(list_paths(src)), 1)
 
     def test_sync_to_dir_local(self):
         path = os.path.join(self.temp_dir.name, 'lorem', 'ipsum.txt')
@@ -398,7 +397,7 @@ def test_sync_to_dir_local(self):
         fs.write_bytes(path, bytes([0x00, 0x01]))
         sync_to_dir(src, dst, delete=True)
 
-        self.assertEqual(len(fs.list_paths(dst)), 1)
+        self.assertEqual(len(list_paths(dst)), 1)
 
     def test_copy_to_local(self):
         path1 = os.path.join(self.temp_dir.name, 'lorem', 'ipsum.txt')
@@ -411,9 +410,8 @@ def test_copy_to_local(self):
         with open(path1, 'w+') as file:
             file.write(self.lorem)
 
-        fs = FileSystem.get_file_system(path1, 'r')
         upload_or_copy(path1, path2)
-        self.assertEqual(len(fs.list_paths(dir2)), 1)
+        self.assertEqual(len(list_paths(dir2)), 1)
 
     def test_last_modified(self):
         path = os.path.join(self.temp_dir.name, 'lorem', 'ipsum1.txt')