Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Make sure you have set up the project properly before running the tests, see abo
1. `python test_report.py`
2. Above command will run all test cases and generate the html report, in `reports` folder at the root level.
3. To run the coverage
1. `coverage run --source=src -m unittest discover -s tests/unit_tests`
1. `python -m coverage run --source=src -m unittest discover -s tests/unit_tests`
2. Above command will run all the unit test cases.
3. To generate the coverage report in console
1. `coverage report`
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ uvicorn==0.20.0
coverage==7.2.7
html_testRunner==1.2.1
httpx==0.24.1
python-osw-validation==0.0.5
python-osw-validation==0.2.0
6 changes: 3 additions & 3 deletions test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Define your test cases
from tests.unit_tests.test_queue_message_content import TestUpload, TestUploadData, TestToJson, TestValidationResult
from tests.unit_tests.test_validation import TestSuccessValidation, TestFailureValidation
from tests.unit_tests.test_validation import TestOtherValidation, TestValidation
from tests.unit_tests.test_osw_validator import TestOSWValidator
from tests.unit_tests.test_main import TestApp

Expand All @@ -15,8 +15,8 @@
test_suite.addTest(unittest.makeSuite(TestUploadData))
test_suite.addTest(unittest.makeSuite(TestToJson))
test_suite.addTest(unittest.makeSuite(TestValidationResult))
test_suite.addTest(unittest.makeSuite(TestSuccessValidation))
test_suite.addTest(unittest.makeSuite(TestFailureValidation))
test_suite.addTest(unittest.makeSuite(TestOtherValidation))
test_suite.addTest(unittest.makeSuite(TestValidation))
test_suite.addTest(unittest.makeSuite(TestOSWValidator))
test_suite.addTest(unittest.makeSuite(TestApp))

Expand Down
Binary file modified tests/unit_tests/test_files/_id_missing.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/edges_invalid.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/invalid.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/invalid_geometry.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/missing_identifier.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/no_entity.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/nodes_invalid.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/points_invalid.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/valid.zip
Binary file not shown.
Binary file modified tests/unit_tests/test_files/wrong_datatype.zip
Binary file not shown.
33 changes: 3 additions & 30 deletions tests/unit_tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
WRONG_DATATYPE_FILE_NAME = 'wrong_datatype.zip'


class TestSuccessValidation(unittest.TestCase):
class TestOtherValidation(unittest.TestCase):

@patch.object(Validation, 'download_single_file')
def setUp(self, mock_download_single_file):
Expand All @@ -44,33 +44,6 @@ def setUp(self, mock_download_single_file):
def tearDown(self):
pass

def test_validate_with_valid_file(self):
# Arrange
file_path = f'{DOWNLOAD_FILE_PATH}/{SUCCESS_FILE_NAME}'
expected_downloaded_file_path = file_path
self.validator.download_single_file = MagicMock(return_value=expected_downloaded_file_path)
Validation.clean_up = MagicMock()

# Act
result = self.validator.validate()

# Assert
self.assertTrue(result.is_valid)

def test_is_osw_valid_with_valid_file(self):
# Arrange
file_path = f'{DOWNLOAD_FILE_PATH}/{SUCCESS_FILE_NAME}'
expected_downloaded_file_path = file_path
self.validator.download_single_file = MagicMock(return_value=expected_downloaded_file_path)
Validation.clean_up = MagicMock()

# Act
result = self.validator.validate()

# Assert
self.assertTrue(result.is_valid)
Validation.clean_up.assert_called_once_with(file_path)

def test_download_single_file(self):
# Arrange
file_upload_path = DOWNLOAD_FILE_PATH
Expand Down Expand Up @@ -121,7 +94,7 @@ def test_clean_up_folder(self):
# self.assertFalse(os.path.exists(directory_name))


class TestFailureValidation(unittest.TestCase):
class TestValidation(unittest.TestCase):

@patch.object(Validation, 'download_single_file')
def setUp(self, mock_download_single_file):
Expand Down Expand Up @@ -175,7 +148,7 @@ def test_is_osw_valid_with_invalid_zip_file(self):

def test_is_osw_valid_with_invalid_format_file(self):
# Arrange
file_path = f'{SAVED_FILE_PATH}/${FAILURE_FILE_NAME}'
file_path = f'{SAVED_FILE_PATH}/{FAILURE_FILE_NAME}'
expected_downloaded_file_path = file_path
self.validator.download_single_file = MagicMock(return_value=expected_downloaded_file_path)
Validation.clean_up = MagicMock()
Expand Down