diff options
author | 2023-03-18 03:02:42 +0400 | |
---|---|---|
committer | 2023-03-18 05:41:23 +0400 | |
commit | cd978fd47679620cf88c5ef4563c413dc3989a56 (patch) | |
tree | 07dea60452185206ed07ddb89fdad8bf0a9de812 /tests/test_integration.py | |
parent | Update Failing Tests (diff) |
Add Python Version Tests
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'tests/test_integration.py')
-rw-r--r-- | tests/test_integration.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/test_integration.py b/tests/test_integration.py index aa21a2d..4a6e811 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -7,7 +7,7 @@ from textwrap import dedent from tests.gunicorn_utils import run_gunicorn -from scripts.python_version import MAIN_VERSION +from scripts.python_version import ALL_VERSIONS, MAIN_VERSION def b64encode_code(data: str): @@ -67,6 +67,34 @@ class IntegrationTests(unittest.TestCase): self.assertEqual(status, 200) self.assertEqual(json.loads(response)["stdout"], expected) + def test_eval_version(self): + """Test eval requests with specific python versions selected.""" + selected = None + for version in ALL_VERSIONS: + if not version.is_main: + selected = version + break + + if selected is None: + # Ideally we'd test with some non-main version to ensure the logic is correct + # but we're likely running under a configuration where a main version doesn't exist + # so we just make the best of it + selected = MAIN_VERSION + + with run_gunicorn(): + response, status = snekbox_request( + { + "input": "import sys; print(sys.version)", + "version": selected.display_name, + } + ) + parsed = json.loads(response) + + self.assertEqual(status, 200) + self.assertEqual(parsed["returncode"], 0) + self.assertEqual(parsed["version"], selected.display_name) + self.assertIn(selected.version_name, parsed["stdout"]) + def test_files_send_receive(self): """Test sending and receiving files to snekbox.""" with run_gunicorn(): |