summaryrefslogtreecommitdiff
path: root/yaksh/tests
diff options
context:
space:
mode:
authorprathamesh2017-08-22 14:57:43 +0530
committerprathamesh2017-08-22 14:57:43 +0530
commit4af405d525a5fdf6dfbcdb386a43e01d6393202e (patch)
tree42ff46a08d3db7cf30e76f06e5061a629f771f64 /yaksh/tests
parentdd617ed43eb67cc6879605c05eaaad99d377e0cc (diff)
parent46d9ccf47dd3cdc54732fdd833f0ee5b30fcd00f (diff)
downloadonline_test-4af405d525a5fdf6dfbcdb386a43e01d6393202e.tar.gz
online_test-4af405d525a5fdf6dfbcdb386a43e01d6393202e.tar.bz2
online_test-4af405d525a5fdf6dfbcdb386a43e01d6393202e.zip
Merge branch 'improve-code-server' of https://github.com/FOSSEE/online_test into improve-code-server
Diffstat (limited to 'yaksh/tests')
-rw-r--r--yaksh/tests/test_code_server.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py
index a73c12f..5f80f2d 100644
--- a/yaksh/tests/test_code_server.py
+++ b/yaksh/tests/test_code_server.py
@@ -157,6 +157,40 @@ class TestCodeServer(unittest.TestCase):
expect = '5 processes, 0 running, 0 queued'
self.assertTrue(expect in data)
+ def test_killing_process_revives_it(self):
+ # Given
+ testdata = {
+ 'metadata': {
+ 'user_answer': 'import sys; sys.exit()',
+ 'language': 'python',
+ 'partial_grading': False
+ },
+ 'test_case_data': [{'test_case': '',
+ '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.assertFalse(data['success'])
+ self.assertTrue('Process ended with exit code' in data['error'][0])
+
+ # Now check the server status to see if the right number
+ # processes are running.
+ url = "http://localhost:%s/" % SERVER_POOL_PORT
+
+ # When
+ response = urllib.request.urlopen(url)
+ data = response.read().decode('utf-8')
+
+ # Then
+ expect = '5 processes, 0 running, 0 queued'
+ self.assertTrue(expect in data)
+
if __name__ == '__main__':
unittest.main()