Skip to content

Commit

Permalink
add test for filtering email
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Mar 26, 2024
1 parent a8c213e commit cb6966f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/crud/test_crud_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,56 @@ def test_match(self):
)


class TestFilterEmail(TestCase):
"""
Make suer that ``Email`` columns can be filtered - i.e. we can pass in
partial emails like ``google.com``.
"""

def setUp(self):
Studio.create_table(if_not_exists=True).run_sync()

def tearDown(self):
Studio.alter().drop_table().run_sync()

def test_filter_email(self):
client = TestClient(PiccoloCRUD(table=Studio))

Studio.insert(
Studio(
{
Studio.name: "Studio 1",
Studio.booking_email: "[email protected]",
Studio.contact_email: "[email protected]",
}
),
Studio(
{
Studio.name: "Studio 2",
Studio.booking_email: "[email protected]",
Studio.contact_email: "[email protected]",
}
),
).run_sync()

response = client.get("/?booking_email=booking_1")
self.assertEqual(response.status_code, 200)

self.assertEqual(
response.json(),
{
"rows": [
{
"booking_email": "[email protected]",
"contact_email": "[email protected]",
"id": 1,
"name": "Studio 1",
}
]
},
)


class TestExcludeSecrets(TestCase):
"""
Make sure that if ``exclude_secrets`` is ``True``, then values for
Expand Down

0 comments on commit cb6966f

Please sign in to comment.