Skip to content

Commit ae4315b

Browse files
committed
Added unit test cases and updated README.md
1 parent 8905030 commit ae4315b

3 files changed

Lines changed: 217 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
### 0.0.17
55
- Added Unit Test Cases
6+
- Updated Readme file
67

78
### 0.0.16
89
- Removed extra logs

README.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,218 @@ response = auth_provider.has_permission(request_params=permission_request)
270270

271271
#### How does Simulated authentication work?
272272
With simulated authentication, the method `has_permission` simply returns the value given in `should_satisfy_all` property in the permission request.
273+
274+
275+
### Testing
276+
277+
The project is configured with `python` to figure out the coverage of the unit tests. All the tests are in `tests` folder.
278+
- To execute the tests, please follow the commands:
279+
280+
`pip install -r requirements.txt`
281+
282+
`unittest discover -v tests/unit_tests`
283+
284+
- To execute the code coverage, please follow the commands:
285+
286+
`coverage run --source=src/python_ms_core -m unittest discover -v tests/unit_tests`
287+
288+
`coverage html` // Can be run after 1st command
289+
290+
`coverage report` // Can be run after 1st command
291+
292+
- After the commands are run, you can check the coverage report in `htmlcov/index.html`. Open the file in any browser, and it shows complete coverage details
293+
- The terminal will show the output of coverage like this
294+
```shell
295+
296+
> coverage run --source=src/python_ms_core -m unittest discover -v tests/unit_tests
297+
test_has_permission (test_auth.abstract.test_authorizer_abstraction.TestAuthorizerAbstract) ... ok
298+
test_get_search_params (test_auth.models.test_permission_request.TestPermissionRequest) ... ok
299+
test_has_permission_with_invalid_permissions (test_auth.provider.test_hosted_authorizer.TestHostedAuthorizer) ... ok
300+
test_has_permission_with_missing_auth_url (test_auth.provider.test_hosted_authorizer.TestHostedAuthorizer) ... ok
301+
test_has_permission_with_valid_permissions (test_auth.provider.test_hosted_authorizer.TestHostedAuthorizer) ... ok
302+
test_has_permission_should_return_should_satisfy_all (test_auth.provider.test_simulated_authorizer.TestSimulatedAuthorizer) ... ok
303+
test_has_permission_should_return_should_satisfy_none (test_auth.provider.test_simulated_authorizer.TestSimulatedAuthorizer) ... ok
304+
test_core_config_auth (test_config.test_cofig.TestCoreConfig) ... ok
305+
test_core_config_auth_url (test_config.test_cofig.TestCoreConfig) ... ok
306+
test_core_config_auth_url_default (test_config.test_cofig.TestCoreConfig) ... ok
307+
test_core_config_logger (test_config.test_cofig.TestCoreConfig) ... ok
308+
test_core_config_provider (test_config.test_cofig.TestCoreConfig) ... ok
309+
test_core_config_provider_default (test_config.test_cofig.TestCoreConfig) ... ok
310+
test_core_config_provider_override (test_config.test_cofig.TestCoreConfig) ... ok
311+
test_core_config_queue (test_config.test_cofig.TestCoreConfig) ... ok
312+
test_core_config_queue_connection (test_config.test_cofig.TestCoreConfig) ... ok
313+
test_core_config_queue_connection_default (test_config.test_cofig.TestCoreConfig) ... ok
314+
test_core_config_queue_name (test_config.test_cofig.TestCoreConfig) ... ok
315+
test_core_config_queue_name_default (test_config.test_cofig.TestCoreConfig) ... ok
316+
test_core_config_storage (test_config.test_cofig.TestCoreConfig) ... ok
317+
test_core_config_storage_connection (test_config.test_cofig.TestCoreConfig) ... ok
318+
test_core_config_storage_connection_default (test_config.test_cofig.TestCoreConfig) ... ok
319+
test_core_config_topic (test_config.test_cofig.TestCoreConfig) ... ok
320+
test_core_config_topic_connection (test_config.test_cofig.TestCoreConfig) ... ok
321+
test_core_config_topic_connection_default (test_config.test_cofig.TestCoreConfig) ... ok
322+
test_local_config_auth (test_config.test_cofig.TestLocalConfig) ... ok
323+
test_local_config_logger (test_config.test_cofig.TestLocalConfig) ... ok
324+
test_local_config_provider (test_config.test_cofig.TestLocalConfig) ... ok
325+
test_local_config_provider_default (test_config.test_cofig.TestLocalConfig) ... ok
326+
test_local_config_queue (test_config.test_cofig.TestLocalConfig) ... ok
327+
test_local_config_queue_connection (test_config.test_cofig.TestLocalConfig) ... ok
328+
test_local_config_queue_connection_default (test_config.test_cofig.TestLocalConfig) ... ok
329+
test_local_config_queue_name (test_config.test_cofig.TestLocalConfig) ... ok
330+
test_local_config_queue_name_default (test_config.test_cofig.TestLocalConfig) ... ok
331+
test_local_config_storage (test_config.test_cofig.TestLocalConfig) ... ok
332+
test_local_config_storage_connection (test_config.test_cofig.TestLocalConfig) ... ok
333+
test_local_config_storage_connection_default (test_config.test_cofig.TestLocalConfig) ... ok
334+
test_local_config_topic (test_config.test_cofig.TestLocalConfig) ... ok
335+
test_local_config_topic_connection (test_config.test_cofig.TestLocalConfig) ... ok
336+
test_local_config_topic_connection_default (test_config.test_cofig.TestLocalConfig) ... ok
337+
test_local_config_auth (test_config.test_cofig.TestUnknownConfig) ... ok
338+
test_unknown_config_logger (test_config.test_cofig.TestUnknownConfig) ... ok
339+
test_unknown_config_provider (test_config.test_cofig.TestUnknownConfig) ... ok
340+
test_unknown_config_queue (test_config.test_cofig.TestUnknownConfig) ... ok
341+
test_unknown_config_queue_connection_default (test_config.test_cofig.TestUnknownConfig) ... ok
342+
test_unknown_config_queue_name_default (test_config.test_cofig.TestUnknownConfig) ... ok
343+
test_unknown_config_storage (test_config.test_cofig.TestUnknownConfig) ... ok
344+
test_unknown_config_storage_connection_default (test_config.test_cofig.TestUnknownConfig) ... ok
345+
test_unknown_config_topic (test_config.test_cofig.TestUnknownConfig) ... ok
346+
test_unknown_config_topic_connection_default (test_config.test_cofig.TestUnknownConfig) ... ok
347+
test_get_authorizer_no_config (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: SIMULATED
348+
ok
349+
test_get_authorizer_with_config_hosted_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: AZURE
350+
ok
351+
test_get_authorizer_with_config_simulated_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: SIMULATED
352+
ok
353+
test_get_authorizer_with_config_unknown_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: UNKNOWN
354+
ok
355+
test_get_logger_azure_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: AZURE
356+
ok
357+
test_get_logger_local_provider (test_core.TestCore) ... ok
358+
test_get_logger_unknown_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: UNKNOWN
359+
ok
360+
test_get_storage_client_azure_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: AZURE
361+
ok
362+
test_get_storage_client_local_provider (test_core.TestCore) ... ok
363+
test_get_storage_client_unknown_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: UNKNOWN
364+
ok
365+
test_get_topic_azure_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: AZURE
366+
ok
367+
test_get_topic_local_provider (test_core.TestCore) ... ok
368+
test_get_topic_unknown_provider (test_core.TestCore) ... 2023-07-03 18:07:41 ERROR Failed to initialization core.get_logger for provider: UNKNOWN
369+
ok
370+
test_add_request (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
371+
test_debug (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
372+
test_error (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
373+
test_info (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
374+
test_record_metric (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
375+
test_warn (test_logger.abstract.test_logger_abstract.TestLoggerAbstract) ... ok
376+
test_add_request (test_logger.test_local_logger.TestLocalLogger) ... ok
377+
test_debug (test_logger.test_local_logger.TestLocalLogger) ... ok
378+
test_error (test_logger.test_local_logger.TestLocalLogger) ... ok
379+
test_info (test_logger.test_local_logger.TestLocalLogger) ... ok
380+
test_record_metric (test_logger.test_local_logger.TestLocalLogger) ... ok
381+
test_warn (test_logger.test_local_logger.TestLocalLogger) ... ok
382+
test_add_request (test_logger.test_logger.TestLogger) ... ok
383+
test_debug (test_logger.test_logger.TestLogger) ... ok
384+
test_error (test_logger.test_logger.TestLogger) ... ok
385+
test_info (test_logger.test_logger.TestLogger) ... ok
386+
test_record_metric (test_logger.test_logger.TestLogger) ... ok
387+
test_warn (test_logger.test_logger.TestLogger) ... ok
388+
test_concrete_queue_has_abstract_methods_implemented (test_queue.abstract.test_queue_abstract.TestQueueAbstract) ... ok
389+
test_concrete_queue_inherits_from_queue_abstract (test_queue.abstract.test_queue_abstract.TestQueueAbstract) ... ok
390+
test_azure_provider_invalid_connection_string (test_queue.config.test_queue_config.TestConfig) ... ok
391+
test_azure_provider_missing_queue_name (test_queue.config.test_queue_config.TestConfig) ... ok
392+
test_azure_provider_valid_connection_string (test_queue.config.test_queue_config.TestConfig) ... ok
393+
test_non_azure_provider (test_queue.config.test_queue_config.TestConfig) ... ok
394+
test_add_message_to_queue (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
395+
test_add_message_to_queue_no_data (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
396+
test_data_from_invalid_string (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
397+
test_data_from_valid_string (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
398+
test_get_items (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
399+
test_remove_message_from_empty_queue (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
400+
test_remove_message_from_queue (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
401+
test_send_queue (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
402+
test_to_dict (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
403+
test_validate_data (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
404+
test_validate_data_invalid_type (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
405+
test_validate_string (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
406+
test_validate_string_invalid_type (test_queue.models.test_queue_message.QueueMessageTestCase) ... ok
407+
test_add_message_to_queue (test_queue.test_local_queue.TestLocalQueue) ... ok
408+
test_add_message_to_queue_with_no_data (test_queue.test_local_queue.TestLocalQueue) ... ok
409+
test_empty_queue (test_queue.test_local_queue.TestLocalQueue) ... ok
410+
test_get_items_from_queue (test_queue.test_local_queue.TestLocalQueue) ... ok
411+
test_remove_message_from_queue (test_queue.test_local_queue.TestLocalQueue) ... ok
412+
test_send_with_data (test_queue.test_local_queue.TestLocalQueue) ... 200
413+
ok
414+
test_send_without_data (test_queue.test_local_queue.TestLocalQueue) ... ok
415+
test_add (test_queue.test_queue.TestQueue) ... ok
416+
test_add_no_data (test_queue.test_queue.TestQueue) ... ok
417+
test_empty (test_queue.test_queue.TestQueue) ... ok
418+
test_get_items (test_queue.test_queue.TestQueue) ... ok
419+
test_remove (test_queue.test_queue.TestQueue) ... ok
420+
test_send_no_data (test_queue.test_queue.TestQueue) ... ok
421+
test_send_with_data (test_queue.test_queue.TestQueue) ... ok
422+
test_bad_request_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
423+
test_conflict_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
424+
test_forbidden_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
425+
test_internal_server_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
426+
test_not_found_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
427+
test_service_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
428+
test_timeout_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
429+
test_too_many_request_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
430+
test_unauthorized_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
431+
test_unprocessable_error (test_resource_errors.test_errors.TestServiceErrors) ... ok
432+
test_get_body_text (test_storage.abstract.test_file_entity.TestFileEntity) ... ok
433+
test_get_remote_url (test_storage.abstract.test_file_entity.TestFileEntity) ... ok
434+
test_get_stream (test_storage.abstract.test_file_entity.TestFileEntity) ... ok
435+
test_init (test_storage.abstract.test_file_entity.TestFileEntity) ... ok
436+
test_upload (test_storage.abstract.test_file_entity.TestFileEntity) ... ok
437+
test_get_container (test_storage.abstract.test_storage_client.TestStorageClient) ... ok
438+
test_get_file (test_storage.abstract.test_storage_client.TestStorageClient) ... ok
439+
test_get_file_from_url (test_storage.abstract.test_storage_client.TestStorageClient) ... ok
440+
test_create_file (test_storage.abstract.test_storage_container.TestStorageContainer) ... ok
441+
test_init (test_storage.abstract.test_storage_container.TestStorageContainer) ... ok
442+
test_list_files (test_storage.abstract.test_storage_container.TestStorageContainer) ... ok
443+
test_azure_provider_invalid_connection_string (test_storage.config.test_storage_config.TestConfig) ... ok
444+
test_azure_provider_missing_queue_name (test_storage.config.test_storage_config.TestConfig) ... ok
445+
test_azure_provider_valid_connection_string (test_storage.config.test_storage_config.TestConfig) ... ok
446+
test_non_azure_provider (test_storage.config.test_storage_config.TestConfig) ... ok
447+
test_default_method (test_storage.models.test_config.TestCoreConfig) ... ok
448+
test_init_with_custom_provider (test_storage.models.test_config.TestCoreConfig) ... ok
449+
test_init_with_default_provider (test_storage.models.test_config.TestCoreConfig) ... ok
450+
test_get_body_text (test_storage.test_azure_file_entity.TestAzureFileEntity) ... ok
451+
test_get_remote_url (test_storage.test_azure_file_entity.TestAzureFileEntity) ... ok
452+
test_get_stream (test_storage.test_azure_file_entity.TestAzureFileEntity) ... ok
453+
test_upload (test_storage.test_azure_file_entity.TestAzureFileEntity) ... ok
454+
test_get_container (test_storage.test_azure_storage_client.TestAzureStorageClient) ... ok
455+
test_get_file (test_storage.test_azure_storage_client.TestAzureStorageClient) ... ok
456+
test_get_file_from_url (test_storage.test_azure_storage_client.TestAzureStorageClient) ... ok
457+
test_create_file (test_storage.test_azure_storage_container.TestAzureStorageContainer) ... ok
458+
test_list_files (test_storage.test_azure_storage_container.TestAzureStorageContainer) ... ok
459+
test_list_files_with_name_starts_with (test_storage.test_azure_storage_container.TestAzureStorageContainer) ... ok
460+
test_get_body_text (test_storage.test_local_file_entity.TestLocalFileEntity) ... ok
461+
test_get_remote_url (test_storage.test_local_file_entity.TestLocalFileEntity) ... ok
462+
test_get_stream (test_storage.test_local_file_entity.TestLocalFileEntity) ... ok
463+
test_upload (test_storage.test_local_file_entity.TestLocalFileEntity) ... ok
464+
test_get_container (test_storage.test_local_storage_client.TestLocalStorageClient) ... ok
465+
test_get_container_without_name (test_storage.test_local_storage_client.TestLocalStorageClient) ... ok
466+
test_get_file (test_storage.test_local_storage_client.TestLocalStorageClient) ... ok
467+
test_get_file_from_url (test_storage.test_local_storage_client.TestLocalStorageClient) ... ok
468+
test_create_file (test_storage.test_local_storage_container.LocalStorageContainerTests) ... ok
469+
test_list_files (test_storage.test_local_storage_container.LocalStorageContainerTests) ... ok
470+
test_init (test_topic.abstract.test_topic_abstract.TestDerivedTopic) ... ok
471+
test_publish (test_topic.abstract.test_topic_abstract.TestDerivedTopic) ... ok
472+
test_subscribe (test_topic.abstract.test_topic_abstract.TestDerivedTopic) ... ok
473+
test_azure_provider_invalid_connection_string (test_topic.config.test_topic_config.TestConfig) ... ok
474+
test_azure_provider_logging_levels (test_topic.config.test_topic_config.TestConfig) ... ok
475+
test_azure_provider_valid_connection_string (test_topic.config.test_topic_config.TestConfig) ... ok
476+
test_non_azure_provider (test_topic.config.test_topic_config.TestConfig) ... ok
477+
test_sender_creation (test_topic.config.test_topic_config.TestConfig) ... ok
478+
test_publish (test_topic.test_local_topic.TestLocalTopic) ... ok
479+
test_subscribe_with_subscription (test_topic.test_local_topic.TestLocalTopic) ... ok
480+
test_publish (test_topic.test_topic.TestTopic) ... ok
481+
test_subscribe_with_subscription (test_topic.test_topic.TestTopic) ... ok
482+
483+
----------------------------------------------------------------------
484+
Ran 174 tests in 8.175s
485+
486+
OK
487+
```

freeze_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
build_date = date.today().strftime('%Y-%m-%d')
1313

14-
version = '0.0.16'
14+
version = '0.0.17'
1515

1616
with open(version_file_path, 'w+') as version_file:
1717
version_file.write("version = '{}'\n".format(version))

0 commit comments

Comments
 (0)