def test_accepts_same_kwargs_as_server_run_test_method(self): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.JobArgumentError: pytest.fail("should not have failed because kwargs are not missing") except cli.MarkUsError: pass
def test_fails_if_no_tests_groups(self): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.TestParameterError: return except cli.MarkUsError: pass
def test_writes_queue_info_to_stdout(self, capfd, pop_interval): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.MarkUsError: pass out, _err = capfd.readouterr() assert re.search(r"^\d+$", out)
def test_can_find_test_files(self): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.TestScriptFilesError: pytest.fail("should not have failed because no test scripts could be found") except cli.MarkUsError: pass
def test_can_find_valid_queue(self): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.InvalidQueueError: pytest.fail("should not have failed because a valid queue is available") except cli.MarkUsError: pass
def test_can_enqueue_test_with_timeout(self, mock_enqueue_call): settings = { "testers": [{"test_data": [{"category": ["admin"], "timeout": 10}]}] } with tmp_script_dir(settings): cli.enqueue_test("Admin", 1, **self.get_kwargs(test_categories=["admin"])) mock_enqueue_call.assert_called_with( ANY, kwargs=ANY, job_id=ANY, timeout=15 )
def test_fails_missing_required_args(self): try: cli.enqueue_test("Admin", 1) except cli.JobArgumentError: return except cli.MarkUsError as e: pytest.fail( f"should have failed because kwargs are missing but instead failed with: {e}" ) pytest.fail("should have failed because kwargs are missing")
def test_fails_if_test_files_do_not_exist(self, non_existant_test_script_dir): try: cli.enqueue_test("Admin", 1, **self.get_kwargs()) except cli.TestScriptFilesError: return except cli.MarkUsError as e: pytest.fail( f"should have failed because no test scripts could be found but instead failed with: {e}" ) pytest.fail("should have failed because no test scripts could be found")
def test_fails_if_cannot_find_valid_queue(self): try: cli.enqueue_test("Tim", None, **self.get_kwargs()) except cli.InvalidQueueError: return except cli.MarkUsError as e: pytest.fail( f"should have failed because a valid queue is not found but instead failed with: {e}" ) pytest.fail("should have failed because a valid queue is not found")
def test_fails_if_no_groups_in_category(self): settings = {"testers": [{"test_data": [{"category": ["admin"]}]}]} with tmp_script_dir(settings): try: cli.enqueue_test( "Admin", 1, **self.get_kwargs(test_categories=["student"]) ) except cli.TestParameterError: return except cli.MarkUsError: pass
def test_can_find_tests_in_given_category(self): settings = { "testers": [{"test_data": [{"category": ["admin"], "timeout": 30}]}] } with tmp_script_dir(settings): try: cli.enqueue_test( "Admin", 1, **self.get_kwargs(test_categories=["admin"]) ) except cli.TestParameterError: pytest.fail("should not have failed to find an admin test") except cli.MarkUsError: pass
def test_cleans_up_files_on_error(self, mock_rmtree): with pytest.raises(Exception): cli.enqueue_test("Admin", 1, **self.get_kwargs(files_path="something"))