|
1 | 1 | import asyncio |
2 | | -from unittest import TestCase |
3 | | - |
4 | | -import asyncpg |
5 | 2 |
|
6 | 3 | from ..base import DBTestCase |
7 | 4 | from ..example_project.tables import Pokemon |
@@ -282,87 +279,3 @@ async def get_pokemon(): |
282 | 279 | response, |
283 | 280 | [{'count': 1}] |
284 | 281 | ) |
285 | | - |
286 | | - |
287 | | -class TestUpdate(DBTestCase): |
288 | | - |
289 | | - def test_update(self): |
290 | | - self.insert_rows() |
291 | | - |
292 | | - async def update_pokemon(): |
293 | | - return await Pokemon.update( |
294 | | - name='kakuna' |
295 | | - ).where( |
296 | | - Pokemon.name == 'weedle' |
297 | | - ).execute() |
298 | | - |
299 | | - async def check_pokemon(): |
300 | | - return await Pokemon.select( |
301 | | - 'name' |
302 | | - ).where( |
303 | | - Pokemon.name == 'kakuna' |
304 | | - ).execute() |
305 | | - |
306 | | - asyncio.run(update_pokemon()) |
307 | | - response = asyncio.run(check_pokemon()) |
308 | | - print(f'response = {response}') |
309 | | - |
310 | | - self.assertEqual( |
311 | | - response, |
312 | | - [{'name': 'kakuna'}] |
313 | | - ) |
314 | | - |
315 | | - |
316 | | -class TestDelete(DBTestCase): |
317 | | - |
318 | | - def test_delete(self): |
319 | | - self.insert_rows() |
320 | | - |
321 | | - async def delete_pokemon(): |
322 | | - return await Pokemon.delete().where( |
323 | | - Pokemon.name == 'weedle' |
324 | | - ).execute() |
325 | | - |
326 | | - async def check_pokemon(): |
327 | | - return await Pokemon.select().where( |
328 | | - Pokemon.name == 'weedle' |
329 | | - ).count().execute() |
330 | | - |
331 | | - asyncio.run(delete_pokemon()) |
332 | | - response = asyncio.run(check_pokemon()) |
333 | | - print(f'response = {response}') |
334 | | - |
335 | | - self.assertEqual( |
336 | | - response, |
337 | | - [{'count': 0}] |
338 | | - ) |
339 | | - |
340 | | - |
341 | | -class TestCreate(DBTestCase): |
342 | | - |
343 | | - def setUp(self): |
344 | | - """ |
345 | | - Need to override, otherwise table will be auto created. |
346 | | - """ |
347 | | - pass |
348 | | - |
349 | | - def test_create_table(self): |
350 | | - async def create_table(): |
351 | | - return await Pokemon.create().execute() |
352 | | - |
353 | | - async def count_rows(): |
354 | | - return await Pokemon.select( |
355 | | - 'name', 'trainer', 'power' |
356 | | - ).count().execute() |
357 | | - |
358 | | - asyncio.run(create_table()) |
359 | | - |
360 | | - # Just do a count to make sure the table was created ok. |
361 | | - response = asyncio.run(count_rows()) |
362 | | - self.assertEqual(response[0]['count'], 0) |
363 | | - |
364 | | - |
365 | | -class TestMetaClass(TestCase): |
366 | | - |
367 | | - def test_tablename(self): |
368 | | - self.assertEqual(Pokemon.Meta.tablename, 'pokemon') |
0 commit comments