From 7a07f00622d4524933904a4661ad5fd6898d1669 Mon Sep 17 00:00:00 2001 From: Albert Hopkins Date: Mon, 3 Jun 2024 17:23:26 -0500 Subject: [PATCH] tests: add test case for cli.apikey.key_names --- tests/test_cli_apikey.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cli_apikey.py b/tests/test_cli_apikey.py index ac8a1b4..499b1fe 100644 --- a/tests/test_cli_apikey.py +++ b/tests/test_cli_apikey.py @@ -197,3 +197,20 @@ def test(self) -> None: parser = ArgumentParser() apikey.parse_args(parser) + + +class KeyNamesTests(TestCase): + def test(self) -> None: + names = ["this", "that", "the", "other"] + + for name in names: + api_key = ApiKey( + name=name, key=apikey.create_api_key(), created=time.localtime() + ) + publisher.repo.api_keys.save(api_key) + + response = apikey.key_names( + prefix="", action=Mock(), parser=Mock(), parsed_args=Mock() + ) + + self.assertEqual(response, sorted(names))