mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fixes tests and some PEP8.
This commit is contained in:
1 parent
483431438a
commit
ef7b4ef020
12 files changed
+39
-40
No files matched your search
@@ -123,7 +123,7 @@ def test_json(tmpdir):
|
||||
assert p.__json__() == {"name": p.name, "project_id": p.id, "temporary": False}
|
||||
|
||||
|
||||
def test_node_working_directory(tmpdir, vm):
|
||||
def test_node_working_directory(tmpdir, node):
|
||||
directory = Config.instance().get_section_config("Server").get("projects_path")
|
||||
|
||||
with patch("gns3server.compute.project.Project.is_local", return_value=True):
|
||||
@@ -186,7 +186,7 @@ def test_project_delete_permission_issue(loop):
|
||||
os.chmod(directory, 700)
|
||||
|
||||
|
||||
def test_project_add_vm(manager):
|
||||
def test_project_add_node(manager):
|
||||
project = Project(project_id=str(uuid4()))
|
||||
node = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
project.add_node(node)
|
||||
|
||||
@@ -164,7 +164,7 @@ def test_connectNotification(compute, async_run):
|
||||
compute._session = AsyncioMagicMock(return_value=ws_mock)
|
||||
compute._session.ws_connect = AsyncioMagicMock(return_value=ws_mock)
|
||||
ws_mock.receive = receive
|
||||
async_run(compute._connectNotification())
|
||||
async_run(compute._connect_notification())
|
||||
|
||||
compute._controller.emit.assert_called_with('test', {'a': 1}, compute_id=compute.id, project_id='42')
|
||||
assert compute._connected is False
|
||||
@@ -186,5 +186,5 @@ def test_streamFile(project, async_run, compute):
|
||||
response = MagicMock()
|
||||
response.status = 200
|
||||
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
|
||||
async_run(compute.streamFile(project, "test/titi"))
|
||||
async_run(compute.steam_file(project, "test/titi"))
|
||||
mock.assert_called_with("GET", "https://example.com:84/v2/compute/projects/{}/stream/test/titi".format(project.id), auth=None)
|
||||
@@ -103,9 +103,9 @@ def test_addComputeConfigFile(controller, controller_config_path, async_run):
|
||||
def test_getCompute(controller, async_run):
|
||||
compute = async_run(controller.add_compute("test1"))
|
||||
|
||||
assert controller.getCompute("test1") == compute
|
||||
assert controller.get_compute("test1") == compute
|
||||
with pytest.raises(aiohttp.web.HTTPNotFound):
|
||||
assert controller.getCompute("dsdssd")
|
||||
assert controller.get_compute("dsdssd")
|
||||
|
||||
|
||||
def test_addComputeLocal(controller, controller_config_path, async_run):
|
||||
@@ -113,8 +113,8 @@ def test_addComputeLocal(controller, controller_config_path, async_run):
|
||||
The local node is the controller itself you can not change the informations
|
||||
"""
|
||||
Config.instance().set("Server", "local", True)
|
||||
async_run(controller.addCompute("local", host="example.org"))
|
||||
assert controller.getCompute("local").host == "localhost"
|
||||
async_run(controller.add_compute("local", host="example.org"))
|
||||
assert controller.get_compute("local").host == "localhost"
|
||||
|
||||
|
||||
def test_addProject(controller, async_run):
|
||||
@@ -129,13 +129,13 @@ def test_addProject(controller, async_run):
|
||||
assert len(controller.projects) == 2
|
||||
|
||||
|
||||
def test_removeProject(controller, async_run):
|
||||
def test_remove_project(controller, async_run):
|
||||
uuid1 = str(uuid.uuid4())
|
||||
|
||||
project1 = async_run(controller.addProject(project_id=uuid1))
|
||||
assert len(controller.projects) == 1
|
||||
|
||||
controller.removeProject(project1)
|
||||
controller.remove_project(project1)
|
||||
assert len(controller.projects) == 0
|
||||
|
||||
|
||||
|
||||
@@ -71,11 +71,11 @@ def test_captures_directory(tmpdir):
|
||||
def test_add_compute(async_run):
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
async_run(project.addCompute(compute))
|
||||
async_run(project.add_compute(compute))
|
||||
assert compute in project._computes
|
||||
|
||||
|
||||
def test_addVM(async_run):
|
||||
def test_add_node(async_run):
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
|
||||
@@ -83,7 +83,7 @@ def test_addVM(async_run):
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
vm = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
|
||||
@@ -173,4 +173,4 @@ def test_read_pcap_from_source(project, async_run):
|
||||
assert link._capture_node is not None
|
||||
|
||||
async_run(link.read_pcap_from_source())
|
||||
link._capture_node["node"].compute.streamFile.assert_called_with(project, "tmp/captures/" + link._capture_file_name)
|
||||
link._capture_node["node"].compute.steam_file.assert_called_with(project, "tmp/captures/" + link._capture_file_name)
|
||||
Reference in new issue
Block a user