def test_runs_with_packaged_code(self, default_hooks): """Test that packaged code is handled correctly.""" result = default_hooks.act_on_cloned_repo(PACKAGED_CODE_REPO) assert result.status == Status.SUCCESS assert (_output.test_result_header( "se.repobee.fibo.FiboTest", NUM_FIBO_TESTS, NUM_FIBO_TESTS, _output.SUCCESS_COLOR, ) in result.msg)
def test_fail_repo(self, default_hooks): """Test with repo that should have test failures.""" result = default_hooks.act_on_cloned_repo(FAIL_REPO) assert result.status == Status.WARNING assert (_output.test_result_header( "PrimeCheckerTest", NUM_PRIME_CHECKER_TESTS, NUM_PRIME_CHECKER_TESTS - 2, _output.FAILURE_COLOR, ) in result.msg)
def test_correct_repo(self, default_hooks): """Test with repo that should not have test failures.""" result = default_hooks.act_on_cloned_repo(SUCCESS_REPO) assert result.status == Status.SUCCESS assert (_output.test_result_header( "FiboTest", NUM_FIBO_TESTS, NUM_FIBO_TESTS, _output.SUCCESS_COLOR, ) in result.msg)
def test_fail_repo(self, default_hooks): """Test with repo that should have test failures.""" result = default_hooks.post_clone(wrap_in_student_repo(FAIL_REPO), api=None) assert result.status == plug.Status.WARNING assert (_output.test_result_header( "PrimeCheckerTest", NUM_PRIME_CHECKER_TESTS, NUM_PRIME_CHECKER_TESTS - 2, _output.FAILURE_COLOR, ) in result.msg)
def test_correct_repo(self, default_hooks): """Test with repo that should not have test failures.""" result = default_hooks.post_clone(wrap_in_student_repo(SUCCESS_REPO), api=None) assert result.status == plug.Status.SUCCESS assert (_output.test_result_header( "FiboTest", NUM_FIBO_TESTS, NUM_FIBO_TESTS, _output.SUCCESS_COLOR, ) in result.msg)
def test_with_abstract_test_class(self, default_hooks): """Test running the plugin when the reference tests include an abstract test class. """ result = default_hooks.act_on_cloned_repo(ABSTRACT_TEST_REPO) assert result.status == Status.SUCCESS assert (_output.test_result_header( "PrimeCheckerTest", NUM_PRIME_CHECKER_TESTS, NUM_PRIME_CHECKER_TESTS, _output.SUCCESS_COLOR, ) in result.msg)
def test_file_access_allowed_with_disabled_security(self): """Test that student code can access files without crashing if security is disabled. """ hooks = setup_hooks(disable_security=True) result = hooks.act_on_cloned_repo(UNAUTHORIZED_READ_FILE_REPO) assert result.status == Status.SUCCESS assert (_output.test_result_header( "FiboTest", NUM_FIBO_TESTS, NUM_FIBO_TESTS, _output.SUCCESS_COLOR, ) in result.msg)
def test_fail_repo_verbose(self, hooks): """Test verbose output on repo that fails tests.""" expected_verbose_msg = """1) isPrimeFalseForComposites(PrimeCheckerTest) java.lang.AssertionError: Expected: is <false> but: was <true> 2) oneIsNotPrime(PrimeCheckerTest) java.lang.AssertionError: Expected: is <false> but: was <true>""" # noqa: W291 result = hooks.post_clone(wrap_in_student_repo(FAIL_REPO), api=None) assert (_output.test_result_header( "PrimeCheckerTest", NUM_PRIME_CHECKER_TESTS, NUM_PRIME_CHECKER_TESTS - 2, _output.FAILURE_COLOR, ) in result.msg) assert expected_verbose_msg in result.msg