From ef75938edbfacc41194ffac83fe51cb69bf7d5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Tue, 1 Oct 2024 14:17:36 +0200 Subject: [PATCH] increase test coverage --- system/t12_api/gpg.py | 2 +- system/t12_api/snapshots.py | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/system/t12_api/gpg.py b/system/t12_api/gpg.py index fb3acd76b..363e198ec 100644 --- a/system/t12_api/gpg.py +++ b/system/t12_api/gpg.py @@ -29,7 +29,7 @@ def check(self): with tempfile.NamedTemporaryFile(suffix=".pub") as keyring: gpgkeyid = "9E3E53F19C7DE460" resp = self.post("/api/gpg/key", json={ - "Keyserver": "keyserver.ubuntu.com", + "Keyserver": "hkp://keyserver.ubuntu.com:80", "Keyring": keyring.name, "GpgKeyID": gpgkeyid }) diff --git a/system/t12_api/snapshots.py b/system/t12_api/snapshots.py index eb2b980fe..9986d03a3 100644 --- a/system/t12_api/snapshots.py +++ b/system/t12_api/snapshots.py @@ -448,6 +448,63 @@ def check(self): }) self.check_equal(resp.status_code, 200) + # dry run, all-matches + resp = self.post("/api/snapshots/pull?dry-run=1&all-matches=1", json={ + 'Source': snapshot_repo_with_libboost, + 'To': snapshot_empty_repo, + 'Destination': snapshot_pull_libboost, + 'Queries': [ + 'libboost-program-options-dev' + ], + 'Architectures': [ + 'amd64' + 'i386' + ] + }) + self.check_equal(resp.status_code, 200) + + # missing argument + resp = self.post("/api/snapshots/pull", json={ + 'Source': snapshot_repo_with_libboost, + 'To': snapshot_empty_repo, + 'Destination': snapshot_pull_libboost, + }) + self.check_equal(resp.status_code, 500) + + # dry run, emtpy architectures + resp = self.post("/api/snapshots/pull?dry-run=1", json={ + 'Source': snapshot_repo_with_libboost, + 'To': snapshot_empty_repo, + 'Destination': snapshot_pull_libboost, + 'Queries': [ + 'libboost-program-options-dev' + ], + 'Architectures': [] + }) + self.check_equal(resp.status_code, 500) + + # dry run, non-existing To + resp = self.post("/api/snapshots/pull", json={ + 'Source': snapshot_repo_with_libboost, + 'To': "asd123", + 'Destination': snapshot_pull_libboost, + 'Queries': [ + 'libboost-program-options-dev' + ] + }) + self.check_equal(resp.status_code, 404) + + # dry run, non-existing source + resp = self.post("/api/snapshots/pull?dry-run=1", json={ + 'Source': "asd123", + 'To': snapshot_empty_repo, + 'Destination': snapshot_pull_libboost, + 'Queries': [ + 'libboost-program-options-dev' + ] + }) + self.check_equal(resp.status_code, 404) + # snapshot pull resp = self.post("/api/snapshots/pull", json={ 'Source': snapshot_repo_with_libboost,