diff --git a/SAS/TMSS/test/t_tmssapp_scheduling_django_API.py b/SAS/TMSS/test/t_tmssapp_scheduling_django_API.py index 719013734259c39a65aa0f8afc9719d3ee25658a..e874abfa07ce6c9e4f0254517e605b0c5d531c90 100755 --- a/SAS/TMSS/test/t_tmssapp_scheduling_django_API.py +++ b/SAS/TMSS/test/t_tmssapp_scheduling_django_API.py @@ -376,6 +376,15 @@ class FilesystemTest(unittest.TestCase): self.assertLess(before, entry.updated_at) self.assertGreater(after, entry.updated_at) + def test_Filesystem_raises_ValueError_on_invalid_directory_name(self): + + # setup + test_data = Filesystem_test_data(directory="/no/trailing/slash") + + # assert + with self.assertRaises(ValueError): + entry = models.Filesystem.objects.create(**test_data) + class ClusterTest(unittest.TestCase): def test_Cluster_gets_created_with_correct_creation_timestamp(self): diff --git a/SAS/TMSS/test/t_tmssapp_specification_django_API.py b/SAS/TMSS/test/t_tmssapp_specification_django_API.py index e994df895e9f5167535d8981ce9ab552bc3cd69b..b2a6a26940dbc92980c3dee255527f1a0e28a837 100755 --- a/SAS/TMSS/test/t_tmssapp_specification_django_API.py +++ b/SAS/TMSS/test/t_tmssapp_specification_django_API.py @@ -249,6 +249,19 @@ class ProjectTest(unittest.TestCase): self.assertLess(before, entry.updated_at) self.assertGreater(after, entry.updated_at) + def test_Project_raises_ValueError_on_invalid_archive_subdirectory_name(self): + + # setup + test_data_1 = Project_test_data(archive_subdirectory="no/trailing/slash") + test_data_2 = Project_test_data(archive_subdirectory="/with/leading/slash/") + + # assert + with self.assertRaises(ValueError): + entry = models.Project.objects.create(**test_data_1) + + with self.assertRaises(ValueError): + entry = models.Project.objects.create(**test_data_2) + class ProjectQuotaTest(unittest.TestCase): def test_ProjectQuota_prevents_missing_project(self): diff --git a/SAS/TMSS/test/tmss_test_data_django_models.py b/SAS/TMSS/test/tmss_test_data_django_models.py index 62e8a4ae088072822af043492c1046ec8784841e..9f0fce4990036d679d83f6ed0e3e69415def009a 100644 --- a/SAS/TMSS/test/tmss_test_data_django_models.py +++ b/SAS/TMSS/test/tmss_test_data_django_models.py @@ -123,7 +123,7 @@ def Cycle_test_data() -> dict: "start": datetime.utcnow().isoformat(), "stop": datetime.utcnow().isoformat()} -def Project_test_data() -> dict: +def Project_test_data(archive_subdirectory="my_project/") -> dict: return { #"cycles": [models.Cycle.objects.create(**Cycle_test_data())], # ManyToMany, use set() "name": 'my_project_' + str(uuid.uuid4()), "description": 'my description ' + str(uuid.uuid4()), @@ -134,7 +134,7 @@ def Project_test_data() -> dict: "private_data": True, "expert": True, "filler": False, - "archive_subdirectory": "my_project/"} + "archive_subdirectory": archive_subdirectory} def ResourceType_test_data() -> dict: return { @@ -431,10 +431,10 @@ def DataproductTransform_test_data() -> dict: "identity": True, "tags": ['tmss', 'testing']} -def Filesystem_test_data() -> dict: +def Filesystem_test_data(directory="/") -> dict: return {"capacity": 1111111111, "cluster": models.Cluster.objects.create(**Cluster_test_data()), - "directory": "/", + "directory": directory, "tags": ['tmss', 'testing']} def Cluster_test_data(name="default cluster") -> dict: