From e7b2d6c873f0bfd502d06c9bd239cedc465e51c5 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 5 Apr 2020 22:58:04 +0200 Subject: test(api): add tests for group export/import API --- tools/python_test_v4.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tools/python_test_v4.py') diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index e0cb3a6..076329b 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -380,6 +380,33 @@ assert len(group1.variables.list()) == 0 # g_l.delete() # assert len(group1.labels.list()) == 0 + +# group import/export +export = group1.exports.create() +assert export.message == "202 Accepted" + +# We cannot check for export_status with group export API +time.sleep(10) + +import_archive = "/tmp/gitlab-group-export.tgz" +import_path = "imported_group" +import_name = "Imported Group" + +with open(import_archive, "wb") as f: + export.download(streamed=True, action=f.write) + +with open(import_archive, "rb") as f: + output = gl.groups.import_group(f, import_path, import_name) +assert output["message"] == "202 Accepted" + +# We cannot check for returned ID with group import API +time.sleep(10) +group_import = gl.groups.get(import_path) + +assert group_import.path == import_path +assert group_import.name == import_name + + # hooks hook = gl.hooks.create({"url": "http://whatever.com"}) assert len(gl.hooks.list()) == 1 -- cgit v1.2.1