Skip to content

Commit cf73072

Browse files
committed
fix test cases
1 parent 9587e75 commit cf73072

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

tests/test_aiohttp.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class User(db.Model):
2222
__tablename__ = 'gino_users'
2323

2424
id = db.Column(db.BigInteger(), primary_key=True)
25-
nickname = db.Column(db.Unicode(), default='noname')
25+
nickname = db.Column('name', db.Unicode(), default='noname')
2626

2727
routes = web.RouteTableDef()
2828

@@ -107,8 +107,7 @@ async def _test(test_client):
107107
response = await test_client.get('/users/1?method=' + method)
108108
assert response.status == 404
109109

110-
response = await test_client.post('/users',
111-
data=dict(name='fantix'))
110+
response = await test_client.post('/users', data=dict(name='fantix'))
112111
assert response.status == 200
113112
assert await response.json() == dict(id=1, nickname='fantix')
114113

tests/test_executemany.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,49 @@ async def test_status(bind):
2020
# noinspection PyUnusedLocal
2121
async def test_all(bind):
2222
result = await User.insert().returning(User.nickname).gino.all(
23-
dict(nickname='1'), dict(nickname='2'))
23+
dict(name='1'), dict(name='2'))
2424
assert result is None
25-
assert len(await User.query.gino.all()) == 2
25+
rows = await User.query.gino.all()
26+
assert len(rows) == 2
27+
assert set(u.nickname for u in rows) == {'1', '2'}
2628

2729
result = await User.insert().gino.all(
28-
dict(nickname='3'), dict(nickname='4'))
30+
dict(name='3'), dict(name='4'))
2931
assert result is None
32+
rows = await User.query.gino.all()
33+
assert len(rows) == 4
34+
assert set(u.nickname for u in rows) == {'1', '2', '3', '4'}
3035

3136

3237
# noinspection PyUnusedLocal
3338
async def test_first(bind):
3439
result = await User.insert().returning(User.nickname).gino.first(
35-
dict(nickname='1'), dict(nickname='2'))
40+
dict(name='1'), dict(name='2'))
3641
assert result is None
42+
rows = await User.query.gino.all()
3743
assert len(await User.query.gino.all()) == 2
44+
assert set(u.nickname for u in rows) == {'1', '2'}
3845

3946
result = await User.insert().gino.first(
40-
dict(nickname='3'), dict(nickname='4'))
47+
dict(name='3'), dict(name='4'))
4148
assert result is None
49+
rows = await User.query.gino.all()
50+
assert len(rows) == 4
51+
assert set(u.nickname for u in rows) == {'1', '2', '3', '4'}
4252

4353

4454
# noinspection PyUnusedLocal
4555
async def test_scalar(bind):
4656
result = await User.insert().returning(User.nickname).gino.scalar(
47-
dict(nickname='1'), dict(nickname='2'))
57+
dict(name='1'), dict(name='2'))
4858
assert result is None
59+
rows = await User.query.gino.all()
4960
assert len(await User.query.gino.all()) == 2
61+
assert set(u.nickname for u in rows) == {'1', '2'}
5062

5163
result = await User.insert().gino.scalar(
52-
dict(nickname='3'), dict(nickname='4'))
64+
dict(name='3'), dict(name='4'))
5365
assert result is None
66+
rows = await User.query.gino.all()
67+
assert len(rows) == 4
68+
assert set(u.nickname for u in rows) == {'1', '2', '3', '4'}

0 commit comments

Comments
 (0)