validations_common.tests.callback_plugins.test_validation_json module¶
test_validation_json¶
Tests for validation_json callback plugin.
- class validations_common.tests.callback_plugins.test_validation_json.TestValidationJson(*args: Any, **kwargs: Any)[source]¶
Bases:
validations_common.tests.base.TestCase
- test_callback_instantiation()[source]¶
Verifying that the CallbackModule is instantiated properly. Test checks presence of CallbackBase in the inheritance chain, in order to ensure that folowing tests are performed with the correct assumptions.
- test_getattribute_invalid()[source]¶
Attempting to call __getattribute__ method with invalid attribute name should result in exception.
- test_getattribute_valid_listed(mock_record_task_result)[source]¶
All of the listed attribute names are checked. The __getattribute__ method returns a partial, the args supplied to it are stored a tuple.
- test_getattribute_valid_unlisted(mock_record_task_result)[source]¶
Since the validation_json.CallbackModule defines it’s own __getattribute__ method, we can’t use dir to safely check the name of attributes individually, as dir itself uses the __getattribute__ method. Instead we check if the namespace of the CallbackBase class is a subset of validation_json.CallbackModule namespace.
- test_new_play(mock_play, mock_play_name, mock_play_uuid)[source]¶
From the callback point of view, both Play and Task are virtually identical. Test involving them are therefore also very similar.
- test_new_task(mock_task, mock_task_name, mock_task_uuid)[source]¶
From the callback point of view, both Play and Task are virtually identical. Test involving them are therefore also very similar.
- test_record_task_result(mock_secondsToStr, mock_time)[source]¶
Method CallbackModule._record_task_result works mostly with dicts and performs few other calls. Therefore the assertions are placed on calls to those few functions and the operations performed with supplied MagicMock objects.
- test_v2_playbook_on_handler_task_start(mock_task, mock_new_task)[source]¶
CallbackModule methods v2_playbook_on_task_start and v2_playbook_on_handler_task_start are virtually identical. The only exception being is_conditional parameter of the v2_playbook_on_task_start, which isn’t used by the method at all. Therefore both of their tests share documentation. In order to verify methods functionality we first append a dummy result at the end of CallbackModule.result list. Simple dictionary is more than sufficient.
- test_v2_playbook_on_task_start(mock_task, mock_new_task)[source]¶
CallbackModule methods v2_playbook_on_task_start and v2_playbook_on_handler_task_start are virtually identical. The only exception being is_conditional parameter of the v2_playbook_on_task_start, which isn’t used by the method at all. Therefore both of their tests share documentation. In order to verify methods functionality we first append a dummy result at the end of CallbackModule.result list. Simple dictionary is more than sufficient.
- validations_common.tests.callback_plugins.test_validation_json.is_iso_time(time_string)[source]¶
Checks if string represents valid time in ISO format, with the default delimiter. Regex is somewhat convoluted, but general enough to last at least until the 9999 AD.
- Returns
True if string matches the pattern. False otherwise.