UT: Combine test{to,from}_json()

This commit is contained in:
Mike Salvatore 2022-07-22 12:07:22 -04:00
parent e5e68f21df
commit 7a507f12ba
1 changed files with 4 additions and 14 deletions

View File

@ -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