-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): added compliance tests (#38)
- comparison config and payload class - stop after first failure Solved: #38
- Loading branch information
1 parent
d44595d
commit e65a4d0
Showing
8 changed files
with
80 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ markers = | |
payload_set: mark test a part of the main payload set (plugin run) | ||
|
||
timeout = 100 | ||
addopts = -x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import inspect | ||
|
||
import pytest | ||
|
||
from tests.fixtures.payload_class import fix_plugin_class | ||
from tests.config.fixtures import fix_plugin_config, project_config, fix_necessary_payload_entry_params | ||
|
||
|
||
@pytest.mark.pre_set | ||
class TestPluginConfigCompliance: | ||
|
||
def test_payload_entry_params_equaled_payload_init_params(self, fix_plugin_config, fix_plugin_class, | ||
fix_necessary_payload_entry_params): | ||
""" | ||
Тест проверяет соответствие начальных параметров в конфигурации и аргументов | ||
""" | ||
full_arg_spec = inspect.getfullargspec(fix_plugin_class.__init__) | ||
entry_params = list(full_arg_spec.args) | ||
|
||
for necessary_param in fix_necessary_payload_entry_params: | ||
assert necessary_param in entry_params | ||
entry_params.remove(necessary_param) | ||
|
||
for param in fix_plugin_config.payload.entry.params: | ||
assert param.key not in fix_necessary_payload_entry_params, f"Custom param should not overload necessary params" | ||
assert param.key in full_arg_spec.args, f'Param `{param.key}` must be processed in the payload class constructor' | ||
|
||
assert set(full_arg_spec.args) == set([param.key for param in fix_plugin_config.payload.entry.params]).union(set(fix_necessary_payload_entry_params)) | ||
|
||
def test_payload_entry_param_key_unique(self, fix_plugin_config): | ||
|
||
param_keys = [] | ||
for param in fix_plugin_config.payload.entry.params: | ||
param_keys.append(param.key) | ||
|
||
assert len(param_keys) == len(set(param_keys)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from typing import Type | ||
|
||
import pytest | ||
|
||
# TODO: Указать путь до класса плагина | ||
from s3_platform_plugin_template.template_payload import MyTemplateParser as imported_payload_class | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def fix_plugin_class() -> Type[imported_payload_class]: | ||
return imported_payload_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters