diff options
author | Prabhu Ramachandran | 2018-04-06 17:32:15 +0530 |
---|---|---|
committer | GitHub | 2018-04-06 17:32:15 +0530 |
commit | a7b0c232991208625564f76a56d078e9391c5cb2 (patch) | |
tree | 1a35de41c7d71fb8f49eb0b12328763502668752 /yaksh/tests | |
parent | 895102248fedae4dded163bfc8db0bb452f5bb6c (diff) | |
parent | 7f04851ccbb4d8b541a3ed38aa13cff36b6e898c (diff) | |
download | online_test-a7b0c232991208625564f76a56d078e9391c5cb2.tar.gz online_test-a7b0c232991208625564f76a56d078e9391c5cb2.tar.bz2 online_test-a7b0c232991208625564f76a56d078e9391c5cb2.zip |
Merge pull request #472 from maheshgudi/fix_no_testcase_bug
Correct answer for no test cases bug fix.
Diffstat (limited to 'yaksh/tests')
-rw-r--r-- | yaksh/tests/test_code_server.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py index 1309624..e2781df 100644 --- a/yaksh/tests/test_code_server.py +++ b/yaksh/tests/test_code_server.py @@ -106,6 +106,40 @@ class TestCodeServer(unittest.TestCase): self.assertFalse(data['success']) self.assertTrue('AssertionError' in data['error'][0]['exception']) + def test_question_with_no_testcases(self): + # Given + testdata = { + 'metadata': { + 'user_answer': 'def f(): return 1', + 'language': 'python', + 'partial_grading': False + }, + 'test_case_data': [] + } + + # When + submit(self.url, '0', json.dumps(testdata), '') + result = get_result(self.url, '0', block=True) + + # Then + data = json.loads(result.get('result')) + self.assertFalse(data['success']) + + # With correct answer and test case + testdata["metadata"]["user_answer"] = 'def f(): return 2' + testdata["test_case_data"] = [{'test_case': 'assert f() == 2', + 'test_case_type': 'standardtestcase', + 'weight': 0.0 + } + ] + # When + submit(self.url, '0', json.dumps(testdata), '') + result = get_result(self.url, '0', block=True) + + # Then + data = json.loads(result.get('result')) + self.assertTrue(data['success']) + def test_multiple_simultaneous_hits(self): # Given results = Queue() |