-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_webcalc.py
47 lines (30 loc) · 985 Bytes
/
test_webcalc.py
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
import pytest
from expecter import expect
from webcalc import app, mongo
@pytest.fixture
def client():
return app.test_client()
@pytest.fixture
def pattern():
with app.app_context():
mongo.db.operations.drop()
mongo.db.operations.insert(
dict(
name="x",
pattern="{{ a * b }}"
)
)
def describe_index():
def it_says_hello(client):
response = client.get('/')
expect(response.data).contains(b"Bell's Hopslam")
def describe_calc():
def when_plus(client):
response = client.get('/4/+/5')
expect(response.data).contains(b"9")
def when_plus_with_floats(client):
response = client.get('/4.6/+/5.0')
expect(response.data).contains(b"9.6")
def from_db(client, pattern):
response = client.get('/4/x/5')
expect(response.data) == b'<img src="https://memegen.link/iw/_/20.jpg">'