File tree Expand file tree Collapse file tree 6 files changed +27
-24
lines changed
Expand file tree Collapse file tree 6 files changed +27
-24
lines changed Original file line number Diff line number Diff line change 1212piccolo.sqlite
1313_build /
1414.coverage
15+ * .sqlite
Original file line number Diff line number Diff line change 44import typing as t
55import warnings
66
7- from .base import Engine
7+ from piccolo . engine .base import Engine
88
99
1010DEFAULT_MODULE_NAME = "piccolo_conf"
Original file line number Diff line number Diff line change 11import asyncio
22from unittest import TestCase
33
4+ import pytest
5+
46from piccolo .engine .finder import engine_finder
7+ from piccolo .engine .postgres import PostgresEngine
8+ from piccolo .engine .sqlite import SQLiteEngine
59
610
711ENGINE = engine_finder ()
812
913
14+ postgres_only = pytest .mark .skipif (
15+ not isinstance (ENGINE , PostgresEngine ), reason = "Only running for Postgres"
16+ )
17+
18+
19+ sqlite_only = pytest .mark .skipif (
20+ not isinstance (ENGINE , SQLiteEngine ), reason = "Only running for SQLite"
21+ )
22+
23+
1024class DBTestCase (TestCase ):
1125 """
1226 Using raw SQL, otherwise tests are too reliant on other Piccolo code.
Original file line number Diff line number Diff line change 22
33from unittest import TestCase
44
5- from ..base import DBTestCase
5+ from ..base import DBTestCase , postgres_only
66from ..example_project .tables import Manager
77
88
9+ @postgres_only
910class TestPool (DBTestCase ):
1011 async def create_pool (self ):
1112 await Manager .Meta .db .start_connnection_pool ()
Original file line number Diff line number Diff line change 11from unittest import TestCase
22
33from ..example_project .tables import Band , Manager
4+ from ..base import postgres_only
45
56
7+ @postgres_only
68class TestTransaction (TestCase ):
7-
89 def test_error (self ):
910 """
1011 Make sure queries in a transaction aren't committed if a query fails.
@@ -13,36 +14,22 @@ def test_error(self):
1314 transaction .add (
1415 Manager .create (),
1516 Band .create (),
16- Band .raw (' MALFORMED QUERY ... SHOULD ERROR' )
17+ Band .raw (" MALFORMED QUERY ... SHOULD ERROR" ),
1718 )
1819 try :
1920 transaction .run_sync ()
2021 except Exception :
2122 pass
22- self .assertTrue (
23- not Band .table_exists ().run_sync ()
24- )
25- self .assertTrue (
26- not Manager .table_exists ().run_sync ()
27- )
23+ self .assertTrue (not Band .table_exists ().run_sync ())
24+ self .assertTrue (not Manager .table_exists ().run_sync ())
2825
2926 def test_succeeds (self ):
3027 transaction = Band .Meta .db .transaction ()
31- transaction .add (
32- Manager .create (),
33- Band .create ()
34- )
28+ transaction .add (Manager .create (), Band .create ())
3529 transaction .run_sync ()
3630
37- self .assertTrue (
38- Band .table_exists ().run_sync ()
39- )
40- self .assertTrue (
41- Manager .table_exists ().run_sync ()
42- )
31+ self .assertTrue (Band .table_exists ().run_sync ())
32+ self .assertTrue (Manager .table_exists ().run_sync ())
4333
44- transaction .add (
45- Band .drop (),
46- Manager .drop ()
47- )
34+ transaction .add (Band .drop (), Manager .drop ())
4835 transaction .run_sync ()
You can’t perform that action at this time.
0 commit comments