def tearDown(self) -> None: result = self.runner.invoke( auth.logout, obj=ClickContext(), ) self.assertEqual(result.output, "[INFO] Logout completed.\n") self.assertEqual(result.exit_code, 0)
def test_no_cluster(self): result = self.runner.invoke( completion, ["bash"], obj=ClickContext(), ) self.assertEqual(result.exit_code, 0)
def test_info_not_existing_orga(self): result = self.runner.invoke( orga.info, "not_existing_orga", obj=ClickContext(), ) self.assertIn("[ERROR] Organization name/slug does not exist.\n", result.output)
def test_status_not_logged(): runner = CliRunner() result = runner.invoke( auth.status, obj=ClickContext(), ) assert result.output == "[INFO] Authentication could not be verified.\n" assert result.exit_code == 0
def test_logout(): runner = CliRunner() result = runner.invoke( auth.logout, obj=ClickContext(), ) assert result.output == "[INFO] Logout completed.\n" assert result.exit_code == 0
def test_info_not_existing_project(self): result = self.runner.invoke( project.info, ["not-existing-project"], obj=ClickContext(), ) self.assertIn("[ERROR] Project name/slug does not exist.\n", result.output)
def test_info_not_existing_deck(self): result = self.runner.invoke( deck.info, ["not_existing_deck"], obj=ClickContext(), ) self.assertIn("[ERROR] Deck name/slug does not exist.\n", result.output)
def test_login_failed(): runner = CliRunner() result = runner.invoke( auth.login, ["--email", "*****@*****.**", "--password", "unsecure"], obj=ClickContext(), ) assert "[ERROR] Login failed. Please check email and password.\n" in result.output assert result.exit_code == 0
def test_project_list(self): result = self.runner.invoke( project.list, obj=ClickContext(), ) self.assertIn("id", result.output) self.assertIn("name", result.output) self.assertIn("buzzword-counter", result.output) self.assertEqual(result.exit_code, 0)
def test_project_info(self): result = self.runner.invoke( project.info, ["buzzword-counter"], obj=ClickContext(), ) self.assertIn("Key", result.output) self.assertIn("Value", result.output) self.assertIn("buzzword-counter", result.output) self.assertEqual(result.exit_code, 0)
def test_orga_list(self): result = self.runner.invoke( orga.list, obj=ClickContext(), ) self.assertIn("id", result.output) self.assertIn("name", result.output) self.assertIn("acme", result.output) self.assertEqual(result.exit_code, 0)
def test_deck_ingress(self): result = self.runner.invoke( deck.ingress, ["4634368f-1751-40ae-9cd7-738fcb656a0d"], obj=ClickContext(), ) self.assertIn( "[ERROR] The project cluster does not exist. Please be sure to run 'unikube project up' first.\n", result.output, ) self.assertEqual(result.exit_code, 1)
def test_orga_info(self): result = self.runner.invoke( orga.info, ["ACME"], obj=ClickContext(), ) self.assertIn("Key", result.output) self.assertIn("Value", result.output) self.assertIn("title", result.output) self.assertIn("ACME", result.output) self.assertEqual(result.exit_code, 0)
def test_status_success(): def verify(): return {"success": True} runner = CliRunner() obj = ClickContext() obj.auth.verify = verify result = runner.invoke( auth.status, obj=obj, ) assert result.output == "[SUCCESS] Authentication verified.\n" assert result.exit_code == 0
def test_login_logout_success(): runner = CliRunner() email = os.getenv("TESTRUNNER_EMAIL") secret = os.getenv("TESTRUNNER_SECRET") assert email is not None assert secret is not None result = runner.invoke( auth.login, ["--email", email, "--password", secret], obj=ClickContext(), ) assert "[SUCCESS] Login successful. Hello Testrunner!\n" in result.output assert result.exit_code == 0 result = runner.invoke( auth.logout, obj=ClickContext(), ) assert result.output == "[INFO] Logout completed.\n" assert result.exit_code == 0
def setUp(self) -> None: self.runner = CliRunner() email = os.getenv("TESTRUNNER_EMAIL") secret = os.getenv("TESTRUNNER_SECRET") self.assertIsNotNone(email) self.assertIsNotNone(secret) self.runner.invoke( auth.login, ["--email", email, "--password", secret], obj=ClickContext(), )
def test_login_wrong_token(): def login(email, password): return {"success": True, "response": {"access_token": "WRONG_TOKEN"}} runner = CliRunner() obj = ClickContext() obj.auth.login = login result = runner.invoke( auth.login, ["--email", "*****@*****.**", "--password", "secure"], obj=obj, ) assert "[ERROR] Login failed. Your token does not match." in result.output assert result.exit_code == 0
def test_no_cluster(self): result = self.runner.invoke( ps, obj=ClickContext(), ) self.assertEqual(result.exit_code, 0)