mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Import API
This commit is contained in:
3 files changed
+60
-6
No files matched your search
@@ -304,3 +304,20 @@ def test_export(server, tmpdir, loop, project):
|
||||
with myzip.open("a") as myfile:
|
||||
content = myfile.read()
|
||||
assert content == b"hello"
|
||||
|
||||
|
||||
def test_import(server, tmpdir, loop):
|
||||
|
||||
with zipfile.ZipFile(str(tmpdir / "test.zip"), 'w') as myzip:
|
||||
myzip.writestr("demo", b"hello")
|
||||
|
||||
project_id = str(uuid.uuid4())
|
||||
|
||||
with open(str(tmpdir / "test.zip"), "rb") as f:
|
||||
response = server.post("/projects/{project_id}/import".format(project_id=project_id), body=f.read(), raw=True)
|
||||
assert response.status == 201
|
||||
|
||||
project = ProjectManager.instance().get_project(project_id=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