This document details the unit test cases for the TDEI-python-osw-validation
Unit test cases are to be written using Python Unittest
- Component -> Specifies the code component
- Class Under Test -> Target method name
- Test Target -> Specific requirement to test_ ex. Functional, security etc.
- Scenario -> Requirement to test
- Expectation -> Expected result from executed scenario
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()| Component | Class Under Test | Test Target | Scenario | Expectation | Status |
|---|---|---|---|---|---|
| Model | Upload | Functional | When requested with upload data | Expect to return same upload data | ✅ |
| Model | Upload | Functional | When requested with upload data_from | Expect to return same upload data_from | ✅ |
| Model | Upload | Functional | When requested with upload message | Expect to return same upload message | ✅ |
| Model | Upload | Functional | When requested with upload id | Expect to return same upload id | ✅ |
| Model | Upload | Functional | When requested with upload type | Expect to return same upload type | ✅ |
| Model | Upload | Functional | When requested with upload publish date | Expect to return same upload publish date | ✅ |
| Model | Upload | Functional | When requested with upload to_json | Expect to return same dict | ✅ |
| -- | -- | -- | -- | -- | -- |
| Model | UploadData | Functional | When requested with stage parameter | Expect to return stage | ✅ |
| Model | UploadData | Functional | When requested with tdei_project_group_id parameter | Expect to return tdei_project_group_id | ✅ |
| Model | UploadData | Functional | When requested with tdei_record_id parameter | Expect to return tdei_record_id | ✅ |
| Model | UploadData | Functional | When requested with user_id parameter | Expect to return user_id | ✅ |
| -- | -- | -- | -- | -- | -- |
| Model | TestRequest | Functional | When requested with tdei_project_group_id parameter | Expect to return tdei_project_group_id | ✅ |
| -- | -- | -- | -- | -- | -- |
| Model | TestMeta | Functional | When requested with file_upload_path parameter | Expect to return file_upload_path | ✅ |
| -- | -- | -- | -- | -- | -- |
| Model | TestResponse | Functional | When requested with response parameter | Expect to return either True or False | ✅ |
| -- | -- | -- | -- | -- | -- |
| Validation | TestSuccessValidation | Functional | When requested for clean_up_file function | Expect to return remove files from local storage | ✅ |
| Validation | TestSuccessValidation | Functional | When requested for clean_up_folder function | Expect to return remove directory from local storage | ✅ |
| Validation | TestSuccessValidation | Functional | When requested for download_single_file function | Expect to download file in local storage | ✅ |
| Validation | TestSuccessValidation | Functional | When requested for is_osw_valid function | Expect to return True | ✅ |
| Validation | TestSuccess Validation | Functional | When requested for validate function | Expect to return True | ✅ |
| -- | -- | -- | -- | -- | -- |
| Validation | TestFailureValidation | Functional | When requested for download_single_file function with invalid endpoint | Expect to throw exception | ✅ |
| Validation | TestFailureValidation | Functional | When requested for is_osw_valid function with invalid file format | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for is_osw_valid function with invalid zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with _id missing in zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid Edges file in zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid Nodes file in zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid Points file in zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid files inside zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with invalid geometry inside zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with missing identifier inside zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with no entiry inside zip file | Expect to return False | ✅ |
| Validation | TestFailureValidation | Functional | When requested for validate function with wrong datatypes inside zip file | Expect to return False | ✅ |
| -- | -- | -- | -- | -- | -- |
| Validator | TestValidator | Functional | When calling send_status function with invalid parameters | Expect to return invalid parameters | ✅ |
| Validator | TestValidator | Functional | When calling subscribe function | Expect to return a message | ✅ |
| Validator | TestValidator | Functional | When calling send_status function with invalid parameters | Expect to return a valid message | ✅ |
| -- | -- | -- | -- | -- | -- |
| Server | TestApp | Functional | When calling get_settings function | Expect to return env variables | ✅ |
| Server | TestApp | Functional | When calling ping function | Expect to return 200 | ✅ |
| Server | TestApp | Functional | When calling root function | Expect to return 200 | ✅ |
In case of integration tests, the system will look for all the integration points to be tested
| Component | Feature under test | Scenario | Expectation | Status |
|---|---|---|---|---|
| Validator | Servicebus integration | Subscribe to upload topic to verify servicebus integration | Expect to return message | ✅ |
| Validator | Servicebus integration | Should publish a message to be received on topic | Expect to receive message on target topic | ✅ |
| Validator | Storage Integration | Fetching a file returns a file entity | Expect to return the file entity |