Skip to content

Commit 6e8e91a

Browse files
committed
added tests for 'main', and moved tests for 'Where'
1 parent a067fcf commit 6e8e91a

File tree

4 files changed

+41
-49
lines changed

4 files changed

+41
-49
lines changed

tests/columns/test_combination.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import unittest
2+
3+
from ..example_project.tables import Band
4+
5+
6+
class TestWhere(unittest.TestCase):
7+
def test_equals(self):
8+
_where = Band.name == "Pythonistas"
9+
sql = _where.__str__()
10+
self.assertEqual(sql, "band.name = 'Pythonistas'")
11+
12+
def test_not_equal(self):
13+
_where = Band.name != "CSharps"
14+
sql = _where.__str__()
15+
self.assertEqual(sql, "band.name != 'CSharps'")
16+
17+
def test_like(self):
18+
_where = Band.name.like("Python%")
19+
sql = _where.__str__()
20+
self.assertEqual(sql, "band.name LIKE 'Python%'")
21+
22+
def test_is_in(self):
23+
_where = Band.name.is_in(["Pythonistas", "Rustaceans"])
24+
sql = _where.__str__()
25+
self.assertEqual(sql, "band.name IN ('Pythonistas', 'Rustaceans')")
26+
27+
def test_not_in(self):
28+
_where = Band.name.not_in(["CSharps"])
29+
sql = _where.__str__()
30+
self.assertEqual(sql, "band.name NOT IN ('CSharps')")

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ async def drop_tables():
1515
"ticket",
1616
"poster",
1717
"migration",
18+
"musician",
19+
"my_table",
1820
]:
1921
await ENGINE._run_in_new_connection(f"DROP TABLE IF EXISTS {table}")
2022

tests/test_field.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/test_main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from unittest import TestCase
2+
3+
from piccolo.main import main
4+
5+
6+
class TestMain(TestCase):
7+
def test_main(self):
8+
# Just make sure it runs without raising any errors.
9+
main()

0 commit comments

Comments
 (0)