Fixes tests and some PEP8.

This commit is contained in:
grossmj committed 2016-05-11 15:19:00 -06:00
1 parent 483431438a
commit ef7b4ef020
12 files changed
+39 -40

No files matched your search

+2 -2
View File
@@ -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)
+6 -6
View File
@@ -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
+3 -3
View File
@@ -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,
+1 -1
View File
@@ -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)