forked from p15670423/monkey
Agent: Add AgentConfiguration.from_json()
This commit is contained in:
parent
8605fd40ac
commit
1f9a056b0b
|
@ -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()
|
||||
|
|
|
@ -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_
|
||||
|
|
Loading…
Reference in New Issue