-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_app.py
More file actions
52 lines (43 loc) · 1.68 KB
/
Copy pathtest_app.py
File metadata and controls
52 lines (43 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
import tempfile
import app as flaskr
import os
import pytest
class FlaskrTestCase(unittest.TestCase):
def setUp(self):
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
flaskr.app.testing = True
self.app = flaskr.app.test_client()
def tearDown(self):
os.close(self.db_fd)
os.unlink(flaskr.app.config['DATABASE'])
def test_get_request(self):
rv = self.app.get('/')
assert b'js' in rv.data
assert b'py' in rv.data
assert b'bash' in rv.data
assert b'java' in rv.data
def test_hello_world(self):
rv = self.app.post('/',
data=dict(input='console.log("hello world")',
in_lang='js',
out_lang='py'))
assert b'print(\\"hello world\\")' in rv.data
def test_java_bash(self):
rv = self.app.post('/',
data=dict(input='System.out.println(1);',
in_lang='java',
out_lang='bash'))
assert b'echo 1' in rv.data
def test_auto_py_to_js(self):
rv = self.app.post('/',
data=dict(input='def test():\n\t1',
in_lang='auto',
out_lang='js'))
assert b'function test() {\\n\\t1\\n}' in rv.data
def test_auto_js_to_py(self):
rv = self.app.post('/',
data=dict(input='let x = 3;',
in_lang='auto',
out_lang='py'))
assert b'x = 3' in rv.data