mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-17 23:08:18 +00:00
Early import project api
This commit is contained in:
@ -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"
|
||||
|
Reference in New Issue
Block a user