-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
is_enabled field support; pytest for unit tests (#121)
* is_enabled field support; pytest for unit tests * fix tests job
- Loading branch information
Showing
8 changed files
with
247 additions
and
114 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
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,18 @@ | ||
.PHONY: check_format format lint type_check check_code unit_test | ||
|
||
check_format: | ||
black deeppavlov_agent/ --diff --check | ||
|
||
format: | ||
black deeppavlov_agent/ | ||
|
||
lint: | ||
flake8 deeppavlov_agent/ --count --show-source --statistics | ||
|
||
type_check: | ||
mypy deeppavlov_agent/ | ||
|
||
check_code: check_format lint type_check | ||
|
||
unit_test: | ||
pytest deeppavlov_agent/tests |
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,78 @@ | ||
from ..parse_config import PipelineConfigParser | ||
from ..core.state_manager import FakeStateManager | ||
|
||
|
||
def test_service_is_enabled(): | ||
config = { | ||
"services": { | ||
"annotator": { | ||
"connector": { | ||
"protocol": "python", | ||
"class_name": "PredefinedOutputConnector", | ||
"output": {"body": "here are my annotations"}, | ||
}, | ||
"state_manager_method": "add_annotation", | ||
"is_enabled": True, | ||
}, | ||
} | ||
} | ||
|
||
parsed_config = PipelineConfigParser(FakeStateManager(), config) | ||
|
||
service = list(filter(lambda x: x.label == "annotator", parsed_config.services))[0] | ||
|
||
assert service is not None | ||
|
||
|
||
def test_service_is_disabled(): | ||
config = { | ||
"services": { | ||
"annotator": { | ||
"connector": { | ||
"protocol": "python", | ||
"class_name": "PredefinedOutputConnector", | ||
"output": {"body": "here are my annotations"}, | ||
}, | ||
"state_manager_method": "add_annotation", | ||
"is_enabled": False, | ||
}, | ||
} | ||
} | ||
|
||
parsed_config = PipelineConfigParser(FakeStateManager(), config) | ||
|
||
assert len(parsed_config.services) == 0 | ||
|
||
|
||
def test_service_in_group_is_disabled(): | ||
config = { | ||
"services": { | ||
"annotators": { | ||
"annotator1": { | ||
"connector": { | ||
"protocol": "python", | ||
"class_name": "PredefinedOutputConnector", | ||
"output": {"body": "annotations1"}, | ||
}, | ||
"state_manager_method": "add_annotation", | ||
}, | ||
"annotator2": { | ||
"connector": { | ||
"protocol": "python", | ||
"class_name": "PredefinedOutputConnector", | ||
"output": {"body": "annotations2"}, | ||
}, | ||
"state_manager_method": "add_annotation", | ||
"is_enabled": False, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
parsed_config = PipelineConfigParser(FakeStateManager(), config) | ||
filtered_services = list( | ||
filter(lambda x: x.label == "annotator2", parsed_config.services) | ||
) | ||
|
||
assert len(filtered_services) == 0 | ||
assert len(parsed_config.services) == 1 |
Oops, something went wrong.