mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-12 19:38:57 +00:00
Fix tests
This commit is contained in:
parent
73a481e510
commit
7de95cd60a
15
docs/api/examples/delete_vpcsiddportsportidnio.txt
Normal file
15
docs/api/examples/delete_vpcsiddportsportidnio.txt
Normal file
@ -0,0 +1,15 @@
|
||||
curl -i -xDELETE 'http://localhost:8000/vpcs/{id:\d+}/ports/{port_id}/nio'
|
||||
|
||||
DELETE /vpcs/{id:\d+}/ports/{port_id}/nio HTTP/1.1
|
||||
|
||||
|
||||
|
||||
HTTP/1.1 200
|
||||
CONNECTION: close
|
||||
CONTENT-LENGTH: 2
|
||||
CONTENT-TYPE: application/json
|
||||
DATE: Thu, 08 Jan 2015 16:09:15 GMT
|
||||
SERVER: Python/3.4 aiohttp/0.13.1
|
||||
X-ROUTE: /vpcs/{id:\d+}/ports/{port_id}/nio
|
||||
|
||||
{}
|
25
docs/api/examples/post_vpcsiddportsportidnio.txt
Normal file
25
docs/api/examples/post_vpcsiddportsportidnio.txt
Normal file
@ -0,0 +1,25 @@
|
||||
curl -i -xPOST 'http://localhost:8000/vpcs/{id:\d+}/ports/{port_id}/nio' -d '{"lport": 4242, "rhost": "127.0.0.1", "rport": 4343, "type": "nio_udp"}'
|
||||
|
||||
POST /vpcs/{id:\d+}/ports/{port_id}/nio HTTP/1.1
|
||||
{
|
||||
"lport": 4242,
|
||||
"rhost": "127.0.0.1",
|
||||
"rport": 4343,
|
||||
"type": "nio_udp"
|
||||
}
|
||||
|
||||
|
||||
HTTP/1.1 200
|
||||
CONNECTION: close
|
||||
CONTENT-LENGTH: 89
|
||||
CONTENT-TYPE: application/json
|
||||
DATE: Thu, 08 Jan 2015 16:09:15 GMT
|
||||
SERVER: Python/3.4 aiohttp/0.13.1
|
||||
X-ROUTE: /vpcs/{id:\d+}/ports/{port_id}/nio
|
||||
|
||||
{
|
||||
"lport": 4242,
|
||||
"rhost": "127.0.0.1",
|
||||
"rport": 4343,
|
||||
"type": "nio_udp"
|
||||
}
|
@ -39,7 +39,7 @@ def test_vpcs_nio_create_udp(server):
|
||||
},
|
||||
example=True)
|
||||
assert response.status == 200
|
||||
assert response.route == '/vpcs/{id}/ports/{port_id}/nio'
|
||||
assert response.route == '/vpcs/{id:\d+}/ports/{port_id}/nio'
|
||||
assert response.json['type'] == 'nio_udp'
|
||||
|
||||
@patch("gns3server.modules.vpcs.vpcs_device.has_privileged_access", return_value=True)
|
||||
@ -50,7 +50,7 @@ def test_vpcs_nio_create_tap(mock, server):
|
||||
'tap_device': 'test',
|
||||
})
|
||||
assert response.status == 200
|
||||
assert response.route == '/vpcs/{vpcs_id}/ports/{port_id}/nio'
|
||||
assert response.route == '/vpcs/{id:\d+}/ports/{port_id}/nio'
|
||||
assert response.json['type'] == 'nio_tap'
|
||||
|
||||
def test_vpcs_delete_nio(server):
|
||||
@ -62,8 +62,8 @@ def test_vpcs_delete_nio(server):
|
||||
'rhost': '127.0.0.1'
|
||||
},
|
||||
)
|
||||
response = server.delete('/vpcs/{}/ports/0/nio'.format(vm.json["vpcs_id"]), example=True)
|
||||
response = server.delete('/vpcs/{}/ports/0/nio'.format(vm.json["id"]), example=True)
|
||||
assert response.status == 200
|
||||
assert response.route == '/vpcs/{id}/ports/{port_id}/nio'
|
||||
assert response.route == '/vpcs/{id:\d+}/ports/{port_id}/nio'
|
||||
|
||||
|
||||
|
@ -90,10 +90,10 @@ def test_add_nio_binding_tap_no_privileged_access(tmpdir, manager):
|
||||
with patch("gns3server.modules.vpcs.vpcs_device.has_privileged_access", return_value=False):
|
||||
with pytest.raises(VPCSError):
|
||||
vm.port_add_nio_binding(0, {"type": "nio_tap", "tap_device": "test"})
|
||||
assert vm._ethernet_adapter.ports[0] is not None
|
||||
assert vm._ethernet_adapter.ports[0] is None
|
||||
|
||||
def test_port_remove_nio_binding(tmpdir, manager):
|
||||
vm = VPCSDevice("test", 42, manager, working_dir=str(tmpdir))
|
||||
nio = vm.port_add_nio_binding(0, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
|
||||
vm.port_remove_nio_binding(0)
|
||||
assert vm._ethernet_adapter.ports[0] == None
|
||||
assert vm._ethernet_adapter.ports[0] is None
|
||||
|
Loading…
Reference in New Issue
Block a user