Rename __json__() to asdict()

This commit is contained in:
grossmj committed 2021-04-17 23:34:28 +09:30
1 parent 44074ff7c9
commit cefab8d362
89 files changed
+286 -282

No files matched your search

+2 -2
View File
@@ -51,7 +51,7 @@ async def test_json_with_ports(on_gns3vm, compute_project, manager):
}
]
cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=ports)
assert cloud.__json__() == {
assert cloud.asdict() == {
"name": "cloud1",
"usage": "",
"node_id": cloud.id,
@@ -84,7 +84,7 @@ def test_json_without_ports(on_gns3vm, compute_project, manager):
"""
cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=None)
assert cloud.__json__() == {
assert cloud.asdict() == {
"name": "cloud1",
"usage": "",
"node_id": cloud.id,
+3 -3
View File
@@ -24,7 +24,7 @@ from gns3server.compute.builtin.nodes.nat import Nat
def test_json_gns3vm(on_gns3vm, compute_project):
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
assert nat.__json__() == {
assert nat.asdict() == {
"name": "nat1",
"usage": "",
"node_id": nat.id,
@@ -47,7 +47,7 @@ def test_json_darwin(darwin_platform, compute_project):
{"name": "eth0", "special": False, "type": "ethernet"},
{"name": "vmnet8", "special": True, "type": "ethernet"}]):
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
assert nat.__json__() == {
assert nat.asdict() == {
"name": "nat1",
"usage": "",
"node_id": nat.id,
@@ -68,7 +68,7 @@ def test_json_windows_with_full_name_of_interface(windows_platform, project):
with patch("gns3server.utils.interfaces.interfaces", return_value=[
{"name": "VMware Network Adapter VMnet8", "special": True, "type": "ethernet"}]):
nat = Nat("nat1", str(uuid.uuid4()), project, MagicMock())
assert nat.__json__() == {
assert nat.asdict() == {
"name": "nat1",
"usage": "",
"node_id": nat.id,
+1 -1
View File
@@ -53,7 +53,7 @@ async def vm(compute_project, manager):
def test_json(vm, compute_project):
assert vm.__json__() == {
assert vm.asdict() == {
'container_id': 'e90e34656842',
'image': 'ubuntu:latest',
'name': 'test',
+1 -1
View File
@@ -472,7 +472,7 @@ async def test_set_process_priority_normal(vm, fake_qemu_img_binary):
def test_json(vm, compute_project):
json = vm.__json__()
json = vm.asdict()
assert json["name"] == vm.name
assert json["project_id"] == compute_project.id
+2 -2
View File
@@ -112,7 +112,7 @@ async def test_variables():
async def test_json():
p = Project(project_id=str(uuid4()))
assert p.__json__() == {
assert p.asdict() == {
"name": p.name,
"project_id": p.id,
"variables": None
@@ -124,7 +124,7 @@ async def test_json_with_variables():
variables = [{"name": "VAR1", "value": "VAL1"}]
p = Project(project_id=str(uuid4()), variables=variables)
assert p.__json__() == {
assert p.asdict() == {
"name": p.name,
"project_id": p.id,
"variables": variables
@@ -107,10 +107,10 @@ async def test_vm_adapter_add_nio_binding_adapter_not_exist(vm, manager, free_co
def test_json(vm, tmpdir, project):
assert vm.__json__()["node_directory"] is None
assert vm.asdict()["node_directory"] is None
project._path = str(tmpdir)
vm._linked_clone = True
assert vm.__json__()["node_directory"] is not None
assert vm.asdict()["node_directory"] is not None
def test_patch_vm_uuid(vm):
+2 -2
View File
@@ -49,10 +49,10 @@ async def test_vm(vm):
@pytest.mark.asyncio
async def test_json(vm, tmpdir, compute_project):
assert vm.__json__()["node_directory"] is not None
assert vm.asdict()["node_directory"] is not None
compute_project._path = str(tmpdir)
vm._linked_clone = True
assert vm.__json__()["node_directory"] is not None
assert vm.asdict()["node_directory"] is not None
@pytest.mark.asyncio