Update tests.

This commit is contained in:
Jeremy committed 2015-01-23 16:38:59 -07:00
1 parent 6460e94311
commit 499a8f10ae
5 files changed
+60 -27

No files matched your search

+13 -13
View File
@@ -45,12 +45,12 @@ def test_affect_uuid():
assert p.uuid == '00010203-0405-0607-0809-0a0b0c0d0e0f'
@patch("gns3server.config.Config.get_section_config", return_value={"local": True})
def test_path(tmpdir):
p = Project(location=str(tmpdir))
assert p.path == os.path.join(str(tmpdir), p.uuid)
assert os.path.exists(os.path.join(str(tmpdir), p.uuid))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, 'vms'))
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
p = Project(location=str(tmpdir))
assert p.path == os.path.join(str(tmpdir), p.uuid)
assert os.path.exists(os.path.join(str(tmpdir), p.uuid))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, 'vms'))
def test_temporary_path():
@@ -58,10 +58,10 @@ def test_temporary_path():
assert os.path.exists(p.path)
@patch("gns3server.config.Config.get_section_config", return_value={"local": False})
def test_changing_location_not_allowed(mock, tmpdir):
with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project(location=str(tmpdir))
def test_changing_location_not_allowed(tmpdir):
with patch("gns3server.config.Config.get_section_config", return_value={"local": False}):
with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project(location=str(tmpdir))
def test_json(tmpdir):
@@ -69,11 +69,11 @@ def test_json(tmpdir):
assert p.__json__() == {"location": p.location, "uuid": p.uuid, "temporary": False}
@patch("gns3server.config.Config.get_section_config", return_value={"local": True})
def test_vm_working_directory(tmpdir, vm):
p = Project(location=str(tmpdir))
assert os.path.exists(p.vm_working_directory(vm))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, vm.module_name, vm.uuid))
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
p = Project(location=str(tmpdir))
assert os.path.exists(p.vm_working_directory(vm))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, vm.module_name, vm.uuid))
def test_mark_vm_for_destruction(vm):
@@ -60,7 +60,6 @@ def test_vm_non_executable_vboxmanage_path(project, manager, loop):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0e", project, manager, "test", False)
vm._find_vboxmanage()
def test_vm_valid_virtualbox_api_version(loop, project, manager):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM._execute", return_value=["API version: 4_3"]):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
@@ -72,6 +71,3 @@ def test_vm_invalid_virtualbox_api_version(loop, project, manager):
with pytest.raises(VirtualBoxError):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
loop.run_until_complete(asyncio.async(vm.create()))
# TODO: find a way to test start, stop, suspend, resume and reload