piccolo 1.11.0__py3-none-any.whl → 1.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- piccolo/__init__.py +1 -1
- piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +35 -30
- piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +29 -21
- piccolo/apps/migrations/auto/migration_manager.py +1 -0
- piccolo/apps/migrations/commands/forwards.py +8 -7
- piccolo/apps/playground/commands/run.py +11 -0
- piccolo/columns/column_types.py +59 -7
- piccolo/columns/reference.py +3 -0
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/METADATA +15 -15
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/RECORD +40 -40
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/WHEEL +1 -1
- tests/apps/migrations/commands/test_forwards_backwards.py +32 -1
- tests/columns/test_array.py +3 -7
- tests/columns/test_bigint.py +3 -9
- tests/columns/test_boolean.py +3 -7
- tests/columns/test_bytea.py +5 -14
- tests/columns/test_choices.py +5 -14
- tests/columns/test_date.py +5 -13
- tests/columns/test_double_precision.py +3 -8
- tests/columns/test_interval.py +5 -13
- tests/columns/test_json.py +9 -26
- tests/columns/test_jsonb.py +3 -11
- tests/columns/test_numeric.py +3 -7
- tests/columns/test_primary_key.py +11 -33
- tests/columns/test_readable.py +5 -7
- tests/columns/test_real.py +3 -8
- tests/columns/test_reference.py +34 -1
- tests/columns/test_reserved_column_names.py +3 -8
- tests/columns/test_smallint.py +3 -8
- tests/columns/test_time.py +5 -14
- tests/columns/test_timestamp.py +5 -13
- tests/columns/test_timestamptz.py +5 -13
- tests/columns/test_uuid.py +3 -7
- tests/columns/test_varchar.py +3 -9
- tests/query/functions/base.py +2 -15
- tests/query/functions/test_datetime.py +2 -4
- tests/query/functions/test_math.py +2 -3
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/LICENSE +0 -0
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/entry_points.txt +0 -0
- {piccolo-1.11.0.dist-info → piccolo-1.13.0.dist-info}/top_level.txt +0 -0
tests/columns/test_timestamp.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import datetime
|
2
|
-
from unittest import TestCase
|
3
2
|
|
4
3
|
from piccolo.columns.column_types import Timestamp
|
5
4
|
from piccolo.columns.defaults.timestamp import TimestampNow
|
6
5
|
from piccolo.table import Table
|
6
|
+
from tests.base import TableTest
|
7
7
|
|
8
8
|
|
9
9
|
class MyTable(Table):
|
@@ -19,12 +19,8 @@ class MyTableDefault(Table):
|
|
19
19
|
created_on = Timestamp(default=TimestampNow())
|
20
20
|
|
21
21
|
|
22
|
-
class TestTimestamp(
|
23
|
-
|
24
|
-
MyTable.create_table().run_sync()
|
25
|
-
|
26
|
-
def tearDown(self):
|
27
|
-
MyTable.alter().drop_table().run_sync()
|
22
|
+
class TestTimestamp(TableTest):
|
23
|
+
tables = [MyTable]
|
28
24
|
|
29
25
|
def test_timestamp(self):
|
30
26
|
"""
|
@@ -46,12 +42,8 @@ class TestTimestamp(TestCase):
|
|
46
42
|
Timestamp(default=datetime.datetime.now(tz=datetime.timezone.utc))
|
47
43
|
|
48
44
|
|
49
|
-
class TestTimestampDefault(
|
50
|
-
|
51
|
-
MyTableDefault.create_table().run_sync()
|
52
|
-
|
53
|
-
def tearDown(self):
|
54
|
-
MyTableDefault.alter().drop_table().run_sync()
|
45
|
+
class TestTimestampDefault(TableTest):
|
46
|
+
tables = [MyTableDefault]
|
55
47
|
|
56
48
|
def test_timestamp(self):
|
57
49
|
"""
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import datetime
|
2
|
-
from unittest import TestCase
|
3
2
|
|
4
3
|
from dateutil import tz
|
5
4
|
|
@@ -10,6 +9,7 @@ from piccolo.columns.defaults.timestamptz import (
|
|
10
9
|
TimestamptzOffset,
|
11
10
|
)
|
12
11
|
from piccolo.table import Table
|
12
|
+
from tests.base import TableTest
|
13
13
|
|
14
14
|
|
15
15
|
class MyTable(Table):
|
@@ -34,12 +34,8 @@ class CustomTimezone(datetime.tzinfo):
|
|
34
34
|
pass
|
35
35
|
|
36
36
|
|
37
|
-
class TestTimestamptz(
|
38
|
-
|
39
|
-
MyTable.create_table().run_sync()
|
40
|
-
|
41
|
-
def tearDown(self):
|
42
|
-
MyTable.alter().drop_table().run_sync()
|
37
|
+
class TestTimestamptz(TableTest):
|
38
|
+
tables = [MyTable]
|
43
39
|
|
44
40
|
def test_timestamptz_timezone_aware(self):
|
45
41
|
"""
|
@@ -78,12 +74,8 @@ class TestTimestamptz(TestCase):
|
|
78
74
|
self.assertEqual(result.created_on.tzinfo, datetime.timezone.utc)
|
79
75
|
|
80
76
|
|
81
|
-
class TestTimestamptzDefault(
|
82
|
-
|
83
|
-
MyTableDefault.create_table().run_sync()
|
84
|
-
|
85
|
-
def tearDown(self):
|
86
|
-
MyTableDefault.alter().drop_table().run_sync()
|
77
|
+
class TestTimestamptzDefault(TableTest):
|
78
|
+
tables = [MyTableDefault]
|
87
79
|
|
88
80
|
def test_timestamptz_default(self):
|
89
81
|
"""
|
tests/columns/test_uuid.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
import uuid
|
2
|
-
from unittest import TestCase
|
3
2
|
|
4
3
|
from piccolo.columns.column_types import UUID
|
5
4
|
from piccolo.table import Table
|
5
|
+
from tests.base import TableTest
|
6
6
|
|
7
7
|
|
8
8
|
class MyTable(Table):
|
9
9
|
uuid = UUID()
|
10
10
|
|
11
11
|
|
12
|
-
class TestUUID(
|
13
|
-
|
14
|
-
MyTable.create_table().run_sync()
|
15
|
-
|
16
|
-
def tearDown(self):
|
17
|
-
MyTable.alter().drop_table().run_sync()
|
12
|
+
class TestUUID(TableTest):
|
13
|
+
tables = [MyTable]
|
18
14
|
|
19
15
|
def test_return_type(self):
|
20
16
|
row = MyTable()
|
tests/columns/test_varchar.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
from unittest import TestCase
|
2
|
-
|
3
1
|
from piccolo.columns.column_types import Varchar
|
4
2
|
from piccolo.table import Table
|
5
3
|
|
6
|
-
from ..base import engines_only
|
4
|
+
from ..base import TableTest, engines_only
|
7
5
|
|
8
6
|
|
9
7
|
class MyTable(Table):
|
@@ -11,7 +9,7 @@ class MyTable(Table):
|
|
11
9
|
|
12
10
|
|
13
11
|
@engines_only("postgres", "cockroach")
|
14
|
-
class TestVarchar(
|
12
|
+
class TestVarchar(TableTest):
|
15
13
|
"""
|
16
14
|
SQLite doesn't enforce any constraints on max character length.
|
17
15
|
|
@@ -20,11 +18,7 @@ class TestVarchar(TestCase):
|
|
20
18
|
Might consider enforcing this at the ORM level instead in the future.
|
21
19
|
"""
|
22
20
|
|
23
|
-
|
24
|
-
MyTable.create_table().run_sync()
|
25
|
-
|
26
|
-
def tearDown(self):
|
27
|
-
MyTable.alter().drop_table().run_sync()
|
21
|
+
tables = [MyTable]
|
28
22
|
|
29
23
|
def test_length(self):
|
30
24
|
row = MyTable(name="bob")
|
tests/query/functions/base.py
CHANGED
@@ -1,21 +1,8 @@
|
|
1
|
-
|
2
|
-
from unittest import TestCase
|
3
|
-
|
4
|
-
from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync
|
1
|
+
from tests.base import TableTest
|
5
2
|
from tests.example_apps.music.tables import Band, Manager
|
6
3
|
|
7
4
|
|
8
|
-
class
|
9
|
-
tables: t.List[t.Type[Table]]
|
10
|
-
|
11
|
-
def setUp(self) -> None:
|
12
|
-
create_db_tables_sync(*self.tables)
|
13
|
-
|
14
|
-
def tearDown(self) -> None:
|
15
|
-
drop_db_tables_sync(*self.tables)
|
16
|
-
|
17
|
-
|
18
|
-
class BandTest(FunctionTest):
|
5
|
+
class BandTest(TableTest):
|
19
6
|
tables = [Band, Manager]
|
20
7
|
|
21
8
|
def setUp(self) -> None:
|
@@ -12,16 +12,14 @@ from piccolo.query.functions.datetime import (
|
|
12
12
|
Year,
|
13
13
|
)
|
14
14
|
from piccolo.table import Table
|
15
|
-
from tests.base import engines_only, sqlite_only
|
16
|
-
|
17
|
-
from .base import FunctionTest
|
15
|
+
from tests.base import TableTest, engines_only, sqlite_only
|
18
16
|
|
19
17
|
|
20
18
|
class Concert(Table):
|
21
19
|
starts = Timestamp()
|
22
20
|
|
23
21
|
|
24
|
-
class DatetimeTest(
|
22
|
+
class DatetimeTest(TableTest):
|
25
23
|
tables = [Concert]
|
26
24
|
|
27
25
|
def setUp(self) -> None:
|
@@ -3,15 +3,14 @@ import decimal
|
|
3
3
|
from piccolo.columns import Numeric
|
4
4
|
from piccolo.query.functions.math import Abs, Ceil, Floor, Round
|
5
5
|
from piccolo.table import Table
|
6
|
-
|
7
|
-
from .base import FunctionTest
|
6
|
+
from tests.base import TableTest
|
8
7
|
|
9
8
|
|
10
9
|
class Ticket(Table):
|
11
10
|
price = Numeric(digits=(5, 2))
|
12
11
|
|
13
12
|
|
14
|
-
class TestMath(
|
13
|
+
class TestMath(TableTest):
|
15
14
|
|
16
15
|
tables = [Ticket]
|
17
16
|
|
File without changes
|
File without changes
|
File without changes
|