summaryrefslogtreecommitdiff
path: root/yaksh/tests/test_code_server.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2016-12-20 16:53:17 +0530
committerGitHub2016-12-20 16:53:17 +0530
commit77e8a6c1cde9190daf9075d71caf6017dc1380e7 (patch)
treec0d4a002bba428269c2f7ba62eb68d24b8cbec5f /yaksh/tests/test_code_server.py
parent1400eeb1d5af1cd1d69e015a19a319ab35d357c4 (diff)
parentbf5b4e7607bae0b81ceeb99e8bf5d750433e92e8 (diff)
downloadonline_test-77e8a6c1cde9190daf9075d71caf6017dc1380e7.tar.gz
online_test-77e8a6c1cde9190daf9075d71caf6017dc1380e7.tar.bz2
online_test-77e8a6c1cde9190daf9075d71caf6017dc1380e7.zip
Merge pull request #163 from ankitjavalkar/code-server-refactor2016-form
Code Evaluator refactoring
Diffstat (limited to 'yaksh/tests/test_code_server.py')
-rw-r--r--yaksh/tests/test_code_server.py48
1 files changed, 30 insertions, 18 deletions
diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py
index 7efd20b..d46c9dd 100644
--- a/yaksh/tests/test_code_server.py
+++ b/yaksh/tests/test_code_server.py
@@ -37,12 +37,15 @@ class TestCodeServer(unittest.TestCase):
def test_infinite_loop(self):
# Given
- testdata = {'user_answer': 'while True: pass',
- 'partial_grading': False,
+ testdata = {'metadata': {'user_answer': 'while True: pass',
+ 'language': 'python',
+ 'partial_grading': False
+ },
'test_case_data': [{'test_case':'assert 1==2',
+ 'test_case_type': 'standardtestcase',
'weight': 0.0
- }
- ]}
+ }]
+ }
# When
result = self.code_server.run_code(
@@ -56,12 +59,15 @@ class TestCodeServer(unittest.TestCase):
def test_correct_answer(self):
# Given
- testdata = {'user_answer': 'def f(): return 1',
- 'partial_grading': False,
+ testdata = {'metadata': { 'user_answer': 'def f(): return 1',
+ 'language': 'python',
+ 'partial_grading': False
+ },
'test_case_data': [{'test_case':'assert f() == 1',
+ 'test_case_type': 'standardtestcase',
'weight': 0.0
- }
- ]}
+ }]
+ }
# When
result = self.code_server.run_code(
@@ -75,12 +81,15 @@ class TestCodeServer(unittest.TestCase):
def test_wrong_answer(self):
# Given
- testdata = {'user_answer': 'def f(): return 1',
- 'partial_grading': False,
+ testdata = {'metadata': { 'user_answer': 'def f(): return 1',
+ 'language': 'python',
+ 'partial_grading': False
+ },
'test_case_data': [{'test_case':'assert f() == 2',
+ 'test_case_type': 'standardtestcase',
'weight': 0.0
- }
- ]}
+ }]
+ }
# When
result = self.code_server.run_code(
@@ -98,12 +107,15 @@ class TestCodeServer(unittest.TestCase):
def run_code():
"""Run an infinite loop."""
- testdata = {'user_answer': 'while True: pass',
- 'partial_grading': False,
- 'test_case_data': [{'test_case':'assert 1==2',
- 'weight': 0.0
- }
- ]}
+ testdata = {'metadata': { 'user_answer': 'while True: pass',
+ 'language': 'python',
+ 'partial_grading': False
+ },
+ 'test_case_data': [{'test_case':'assert 1==2',
+ 'test_case_type': 'standardtestcase',
+ 'weight': 0.0
+ }]
+ }
result = self.code_server.run_code(
'python', 'standardtestcase', json.dumps(testdata), ''
)