Skip to content

Commit 87971cc

Browse files
authored
Merge pull request #65 from TaskarCenterAtUW/dev
[Stage] OSW 0.3 Support
2 parents 74d9cdf + 7b86ee0 commit 87971cc

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ python-ms-core==0.0.23
44
uvicorn==0.20.0
55
html_testRunner==1.2.1
66
geopandas==0.14.4
7-
python-osw-validation==0.2.14
7+
python-osw-validation==0.3.2

tests/unit_tests/test_config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import unittest
33
from unittest.mock import patch
44
from src.config import Settings
5+
import importlib
56

67

78
class TestSettings(unittest.TestCase):
@@ -34,9 +35,12 @@ def test_settings_with_invalid_auth_simulate(self):
3435
settings = Settings()
3536
self.assertEqual(settings.auth_provider, 'Hosted')
3637

37-
@patch.dict(os.environ, {}, clear=True)
38+
@patch.dict(os.environ, {'CONTAINER_NAME': 'osw'}, clear=True)
3839
def test_default_settings(self):
39-
settings = Settings()
40+
# Reload config to pick up the patched environment and bypass .env values
41+
from src import config
42+
importlib.reload(config)
43+
settings = config.Settings()
4044
self.assertEqual(settings.app_name, 'python-osw-validation')
4145
self.assertEqual(settings.event_bus.container_name, 'osw')
4246
self.assertIsNone(settings.auth_permission_url)

tests/unit_tests/test_validation.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,40 @@ def test_validate_invalid_file_with_errors(self, mock_download_file, mock_clean_
8989
"""Test the validate method for a invalid file."""
9090
mock_download_file.return_value = f'{SAVED_FILE_PATH}/{FAILURE_FILE_NAME}'
9191
error_in_file = 'wa.microsoft.graph.edges.OSW.geojson'
92-
feature_indexes = [3, 6, 8, 25]
93-
error_message = "Additional properties are not allowed ('crossing' was unexpected)"
92+
expected_errors = [
93+
{
94+
'feature_index': 3,
95+
'error_message': "Additional properties are not allowed ('crossing' was unexpected)"
96+
},
97+
{
98+
'feature_index': 6,
99+
'error_message': "Additional properties are not allowed ('crossing' was unexpected)"
100+
},
101+
{
102+
'feature_index': 8,
103+
'error_message': "Additional properties are not allowed ('crossing' was unexpected)"
104+
},
105+
{
106+
'feature_index': 25,
107+
'error_message': "Additional properties are not allowed ('crossing' was unexpected)"
108+
},
109+
{
110+
'feature_index': 27,
111+
'error_message': "Additional properties are not allowed ('crossing' was unexpected)"
112+
}
113+
]
94114
# Act
95115
result = self.validation.validate(max_errors=10)
96116

97117
# Assert that validation is marked as valid
98118
self.assertFalse(result.is_valid)
99119
errors = json.loads(result.validation_message)
100-
count = 0
101-
for error in errors:
120+
self.assertEqual(len(errors), len(expected_errors))
121+
122+
for expected, error in zip(expected_errors, errors):
102123
self.assertEqual(error['filename'], error_in_file)
103-
self.assertEqual(error['error_message'][0], error_message)
104-
self.assertEqual(error['feature_index'], feature_indexes[count])
105-
count += 1
124+
self.assertEqual(error['feature_index'], expected['feature_index'])
125+
self.assertEqual(error['error_message'][0], expected['error_message'])
106126
# Ensure clean_up is called twice (once for the file, once for the folder)
107127
self.assertEqual(mock_clean_up.call_count, 2)
108128

0 commit comments

Comments
 (0)