Skip to content

Commit 2ec6943

Browse files
committed
CRF adding comments and pk
1 parent 80a8ccf commit 2ec6943

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/test_crud.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,15 @@ class Game(db.Model):
251251
try:
252252
game_1 = await Game.create(game_id='1', channel_id='X')
253253
game_2 = await Game.create(game_id='2', channel_id='Y')
254+
255+
# ordinary update should be fine
254256
uq = game_1.update(game_id='3')
257+
255258
with pytest.raises(TypeError,
256259
match='Model Game has no table, primary key'):
260+
# but applying the updates to DB should fail
257261
await uq.apply()
262+
258263
with pytest.raises(LookupError,
259264
match='Instance-level CRUD operations not allowed'):
260265
await game_2.delete()
@@ -265,7 +270,9 @@ class Game(db.Model):
265270
match='Instance-level CRUD operations not allowed'):
266271
await game_2.select('game_id')
267272

273+
# previous ordinary update still in effect
268274
assert game_1.game_id == '3'
275+
269276
assert await Game.select('game_id').gino.all() == [('1',), ('2',)]
270277

271278
Game.lookup = lambda self: Game.game_id == self.game_id

tests/test_json.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ async def test_non_jsonb(bind):
9393
class News(db.Model):
9494
__tablename__ = 'news'
9595

96+
id = db.Column(db.Integer(), primary_key=True)
9697
profile = db.Column(JSON(), nullable=False, server_default='{}')
9798
visits = db.IntegerProperty(default=0)
9899

99-
def lookup(self):
100-
return True
101-
102100
await News.gino.create()
103101
try:
104102
news = await News.create()

0 commit comments

Comments
 (0)