Early import project api

This commit is contained in:
Julien Duponchelle committed 2016-07-21 14:48:13 +02:00
1 parent 14f6bd60fb
commit b5ab53bbe9
8 files changed
+221 -4

No files matched your search

+2 -2
View File
@@ -221,12 +221,12 @@ def test_export(http_compute, tmpdir, loop, project):
assert content == b"hello"
def test_import(http_compute, tmpdir, loop, project):
def test_import(http_compute, tmpdir, loop):
with zipfile.ZipFile(str(tmpdir / "test.zip"), 'w') as myzip:
myzip.writestr("demo", b"hello")
project_id = project.id
project_id = str(uuid.uuid4())
with open(str(tmpdir / "test.zip"), "rb") as f:
response = http_compute.post("/projects/{project_id}/import".format(project_id=project_id), body=f.read(), raw=True)
@@ -202,3 +202,21 @@ def test_write_file(http_controller, tmpdir, project):
response = http_controller.post("/projects/{project_id}/files/../hello".format(project_id=project.id), raw=True)
assert response.status == 403
def test_import(http_controller, tmpdir, controller):
with zipfile.ZipFile(str(tmpdir / "test.zip"), 'w') as myzip:
myzip.writestr("project.gns3", b'{"version": "2.0.0", "name": "test"}')
myzip.writestr("demo", b"hello")
project_id = str(uuid.uuid4())
with open(str(tmpdir / "test.zip"), "rb") as f:
response = http_controller.post("/projects/{project_id}/import".format(project_id=project_id), body=f.read(), raw=True)
assert response.status == 201
project = controller.get_project(project_id)
with open(os.path.join(project.path, "demo")) as f:
content = f.read()
assert content == "hello"