def test_testcases_factorial(self): program = """ def factorial(n): return 1 if n == 1 else n * factorial(n-1) """ challenge = self.CreateChallenge(name_persistent="Factorial") TestCase( challenge=challenge.key, statement="factorial(3)", expected="6").put() challenge = Challenge.query().filter( Challenge.name_persistent == 'Factorial').fetch(1)[0] review, output = program_tester.run_testcases(program, challenge) self.assertEquals(review, Review.CORRECT)
def handle_automatic_review( attempt_key, challenge_key, jeeqser_challenge_key, program): """Handles submission review for automatic review challenges.""" attempt, challenge, jeeqser_challenge = ndb.get_multi( [ndb.Key(urlsafe=attempt_key), ndb.Key(urlsafe=challenge_key), ndb.Key(urlsafe=jeeqser_challenge_key)]) vote, output = program_tester.run_testcases( program, challenge) robot = core.get_jeeqs_robot() feedback = Feedback( parent=attempt.key, attempt=attempt.key, author=robot.key, attempt_author=attempt.author, markdown=output, content=markdown.markdown(output, ['codehilite', 'mathjax']), vote=vote) persist_testcase_results( attempt.key, jeeqser_challenge.key, feedback, robot.key)