Agent: Add AgentConfiguration.from_json()

This commit is contained in:
Mike Salvatore 2022-06-24 11:51:33 -04:00
parent 8605fd40ac
commit 1f9a056b0b
2 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,10 @@ class AgentConfiguration:
def from_dict(dict_: dict):
return AgentConfigurationSchema().load(dict_)
@staticmethod
def from_json(config_json: dict):
return AgentConfigurationSchema().loads(config_json)
class AgentConfigurationSchema(Schema):
keep_tunnel_open_time = fields.Float()

View File

@ -189,3 +189,12 @@ def test_from_dict():
config = AgentConfiguration.from_dict(dict_)
assert schema.dump(config) == dict_
def test_from_json():
schema = AgentConfigurationSchema()
dict_ = json.loads(DEFAULT_AGENT_CONFIGURATION_JSON)
config = AgentConfiguration.from_json(DEFAULT_AGENT_CONFIGURATION_JSON)
assert schema.dump(config) == dict_