-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_schema.py
More file actions
33 lines (29 loc) · 981 Bytes
/
test_schema.py
File metadata and controls
33 lines (29 loc) · 981 Bytes
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
from snapshottest import TestCase
from sqlalchemy import create_engine
from vertebrale.database import db_session, init_db
from graphene.test import Client
from vertebrale.schema import schema
class TestSchema(TestCase):
def setUp(self):
engine = create_engine('sqlite:///:memory:')
db_session.configure(bind=engine)
init_db(engine)
from vertebrale.models import Food
db_session.add(Food(name='A', energy=1))
db_session.add(Food(name='B', energy=1))
db_session.commit()
self.client = Client(schema)
def tearDown(self):
db_session.remove()
def test_food(self):
self.assertMatchSnapshot(self.client.execute('''{ foods { name } }'''))
def test_filter_food(self):
query = ''' {
foods(name: "A") {
id
name
energy
}
}
'''.strip()
self.assertMatchSnapshot(self.client.execute(query))