Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Nov 2, 2023
1 parent d0b61a4 commit d6f9e0d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/utils/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
Secret,
Text,
Time,
Timestamp,
Timestamptz,
Varchar,
)
from piccolo.columns.column_types import ForeignKey
Expand Down Expand Up @@ -201,6 +203,29 @@ class Concert(Table):
)


class TestTimestamptzColumn(TestCase):
def test_timestamptz_widget(self):
"""
Make sure that we indicate that `Timestamptz` columns require a special
widget in Piccolo Admin.
"""

class Concert(Table):
starts_on_1 = Timestamptz()
starts_on_2 = Timestamp()

pydantic_model = create_pydantic_model(table=Concert)

properties = pydantic_model.model_json_schema()["properties"]

self.assertEqual(
properties["starts_on_1"]["extra"]["widget"],
"timestamptz",
)

self.assertIsNone(properties["starts_on_2"]["extra"].get("widget"))


class TestUUIDColumn(TestCase):
class Ticket(Table):
code = UUID()
Expand Down

0 comments on commit d6f9e0d

Please sign in to comment.