Create/update project on compute when variables changes

This commit is contained in:
ziajka committed 2018-05-09 15:29:35 +02:00
1 parent 83445214be
commit 7b3d5ae5e3
9 files changed
+98 -11

No files matched your search

+7
View File
@@ -205,3 +205,10 @@ def test_emit(async_run):
(action, event, context) = async_run(queue.get(0.5))
assert action == "test"
assert context["project_id"] == project.id
def test_update_project(loop):
variables = [{"name": "TEST", "value": "VAL"}]
project = Project(project_id=str(uuid.uuid4()))
loop.run_until_complete(asyncio.async(project.update(variables=variables)))
assert project.variables == variables
+21 -4
View File
@@ -85,13 +85,27 @@ def test_json(tmpdir):
def test_update(controller, async_run):
project = Project(controller=controller, name="Hello")
controller._notification = MagicMock()
assert project.name == "Hello"
async_run(project.update(name="World"))
assert project.name == "World"
controller.notification.emit.assert_any_call("project.updated", project.__json__())
def test_update_on_compute(controller, async_run):
variables = [{"name": "TEST", "value": "VAL1"}]
compute = MagicMock()
compute.id = "local"
project = Project(controller=controller, name="Test")
project._project_created_on_compute = [compute]
controller._notification = MagicMock()
async_run(project.update(variables=variables))
compute.put.assert_any_call('/projects/{}'.format(project.id), {
"variables": variables
})
def test_path(tmpdir):
directory = Config.instance().get_section_config("Server").get("projects_path")
@@ -150,7 +164,8 @@ def test_add_node_local(async_run, controller):
compute.post.assert_any_call('/projects', data={
"name": project._name,
"project_id": project._id,
"path": project._path
"path": project._path,
"variables": None
})
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id,
@@ -178,7 +193,8 @@ def test_add_node_non_local(async_run, controller):
compute.post.assert_any_call('/projects', data={
"name": project._name,
"project_id": project._id
"project_id": project._id,
"variables": None
})
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id,
@@ -218,7 +234,8 @@ def test_add_node_from_appliance(async_run, controller):
compute.post.assert_any_call('/projects', data={
"name": project._name,
"project_id": project._id,
"path": project._path
"path": project._path,
"variables": None
})
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id,
+2
View File
@@ -53,6 +53,8 @@ def test_project_to_topology_empty(tmpdir):
"drawings": []
},
"type": "topology",
"supplier": None,
"variables": None,
"version": __version__
}
@@ -91,6 +91,23 @@ def test_delete_project(http_compute, project):
assert mock.called
def test_update_project(http_compute):
query = {"name": "test", "project_id": "51010203-0405-0607-0809-0a0b0c0d0e0f"}
response = http_compute.post("/projects", query)
assert response.status == 201
query = {
"variables": [{"name": "TEST1", "value": "VAL1"}]
}
response = http_compute.put(
"/projects/{project_id}".format(project_id="51010203-0405-0607-0809-0a0b0c0d0e0f"),
query,
example=True
)
assert response.status == 200
assert response.json["variables"] == [{"name": "TEST1", "value": "VAL1"}]
def test_delete_project_invalid_uuid(http_compute):
response = http_compute.delete("/projects/{project_id}".format(project_id=uuid.uuid4()))
assert response.status == 404