This is an automated email from the ASF dual-hosted git repository.
eamonford pushed a commit to branch tests
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
The following commit(s) were added to refs/heads/tests by this push:
new e2ce8d2 wip tests
e2ce8d2 is described below
commit e2ce8d2275b2d8293dee0e2837f60e6eba3b8b90
Author: Eamon Ford <[email protected]>
AuthorDate: Mon Jun 15 10:19:53 2020 -0700
wip tests
---
.../services/CollectionWatcher.py | 4 +--
.../tests/services/test_CollectionWatcher.py | 39 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git
a/collection_manager/collection_manager/services/CollectionWatcher.py
b/collection_manager/collection_manager/services/CollectionWatcher.py
index 8b10df4..65807c9 100644
--- a/collection_manager/collection_manager/services/CollectionWatcher.py
+++ b/collection_manager/collection_manager/services/CollectionWatcher.py
@@ -60,8 +60,8 @@ class CollectionWatcher:
f"Ignoring collection '{collection.dataset_id}' until
its path is fixed.")
return False
if directory == os.path.dirname(self._collections_path):
- logger.error(f"Collection {collection.dataset_id} uses granule
directory {collection.path} "
- f"which is the same directory as the collection
configuration file, "
+ logger.error(f"Collection {collection.dataset_id} has granule path
{collection.path} "
+ f"which uses same directory as the collection
configuration file, "
f"{self._collections_path}. The granules need to be
in their own directory. "
f"Ignoring collection {collection.dataset_id} for
now.")
return False
diff --git a/collection_manager/tests/services/test_CollectionWatcher.py
b/collection_manager/tests/services/test_CollectionWatcher.py
index 9a1f50c..09300b3 100644
--- a/collection_manager/tests/services/test_CollectionWatcher.py
+++ b/collection_manager/tests/services/test_CollectionWatcher.py
@@ -74,6 +74,45 @@ class TestCollectionWatcher(unittest.TestCase):
self.assertEquals(len(updated_collections), 1)
+ def test_collection_is_valid(self):
+ collections_path = os.path.join(os.path.dirname(__file__),
'../resources/collections.yml')
+ collection_watcher = CollectionWatcher(collections_path, Mock(),
Mock())
+
+ collection = Collection(dataset_id="test_dataset",
+ path="/absolute/path",
+ variable="test_variable",
+ historical_priority=1,
+ forward_processing_priority=2,
+ date_from=None,
+ date_to=None)
+ self.assertTrue(collection_watcher._collection_is_valid(collection))
+
+ def test_collection_is_valid_with_relative_path(self):
+ collections_path = os.path.join(os.path.dirname(__file__),
'../resources/collections.yml')
+ collection_watcher = CollectionWatcher(collections_path, Mock(),
Mock())
+
+ collection = Collection(dataset_id="test_dataset",
+ path="relative/path",
+ variable="test_variable",
+ historical_priority=1,
+ forward_processing_priority=2,
+ date_from=None,
+ date_to=None)
+ self.assertFalse(collection_watcher._collection_is_valid(collection))
+
+ def test_collection_is_valid_with_conflicting_path(self):
+ collections_path = os.path.join(os.path.dirname(__file__),
'/resources/collections.yml')
+ collection_watcher = CollectionWatcher(collections_path, Mock(),
Mock())
+
+ collection = Collection(dataset_id="test_dataset",
+ path="/resources/*.nc",
+ variable="test_variable",
+ historical_priority=1,
+ forward_processing_priority=2,
+ date_from=None,
+ date_to=None)
+ self.assertFalse(collection_watcher._collection_is_valid(collection))
+
def test_collection_callback_is_called(self):
with tempfile.NamedTemporaryFile("w+b", buffering=0) as
collections_config:
granule_dir = tempfile.TemporaryDirectory()