From 7a507f12ba7fea18183a707076df18718de1f65e Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 22 Jul 2022 12:07:22 -0400 Subject: [PATCH] UT: Combine test{to,from}_json() --- .../configuration/test_agent_configuration.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py index 84320ffff..928c8d0ec 100644 --- a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py @@ -28,7 +28,6 @@ from tests.common.example_agent_configuration import ( ) from common.configuration import AgentConfiguration, InvalidConfigurationError -from common.configuration.agent_configuration import AgentConfigurationSchema from common.configuration.agent_sub_configuration_schemas import ( CustomPBAConfigurationSchema, ExploitationConfigurationSchema, @@ -192,14 +191,11 @@ def test_from_mapping__invalid_data(): AgentConfiguration.from_mapping(dict_) -def test_from_json(): - schema = AgentConfigurationSchema() - dict_ = deepcopy(AGENT_CONFIGURATION) +def test_to_from_json(): + original_config = AgentConfiguration.from_mapping(AGENT_CONFIGURATION) + config_json = AgentConfiguration.to_json(original_config) - config = AgentConfiguration.from_json(json.dumps(dict_)) - - assert isinstance(config, AgentConfiguration) - assert schema.dump(config) == dict_ + assert AgentConfiguration.from_json(config_json) == original_config def test_from_json__invalid_data(): @@ -208,9 +204,3 @@ def test_from_json__invalid_data(): with pytest.raises(InvalidConfigurationError): AgentConfiguration.from_json(json.dumps(invalid_dict)) - - -def test_to_json(): - config = deepcopy(AGENT_CONFIGURATION) - - assert json.loads(AgentConfiguration.to_json(config)) == AGENT_CONFIGURATION