Skip to content

Commit 0ef521e

Browse files
committed
fixing tests
1 parent 7a6c2ea commit 0ef521e

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

tests/test_alter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def test_rename(self):
1616

1717
rename_query.run_sync()
1818

19-
# The problem now is select * has changed
20-
# Need to use a raw select query instead ...
21-
select_query = Band.select
19+
select_query = Band.raw('SELECT * FROM band')
2220
response = select_query.run_sync()
2321

2422
column_names = response[0].keys()
@@ -36,7 +34,7 @@ def test_drop(self):
3634
Band.popularity,
3735
).run_sync()
3836

39-
response = Band.select.run_sync()
37+
response = Band.raw('SELECT * FROM band').run_sync()
4038

4139
column_names = response[0].keys()
4240
self.assertTrue(
@@ -60,8 +58,7 @@ def test_add(self):
6058
)
6159
add_query.run_sync()
6260

63-
select_query = Band.select
64-
response = select_query.run_sync()
61+
response = Band.raw('SELECT * FROM band').run_sync()
6562

6663
column_names = response[0].keys()
6764
self.assertTrue('weight' in column_names)

tests/test_field.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
import unittest
22

33
from piccolo import columns
4+
from piccolo.table import Table
45

56

6-
name_column = columns.Varchar()
7-
# Usually this is handled by the Table MetaClass:
8-
name_column._name = 'name'
7+
class TestTable(Table):
8+
name = columns.Varchar()
99

1010

1111
class TestColumns(unittest.TestCase):
1212

1313
def test_equals(self):
14-
_where = (name_column == 'Pythonistas')
14+
_where = (TestTable.name == 'Pythonistas')
1515
sql = _where.__str__()
1616
print(sql)
17-
self.assertEqual(sql, "name = 'Pythonistas'")
17+
self.assertEqual(sql, "test_table.name = 'Pythonistas'")
1818

1919
def test_not_equal(self):
20-
_where = (name_column != 'CSharps')
20+
_where = (TestTable.name != 'CSharps')
2121
sql = _where.__str__()
2222
print(sql)
23-
self.assertEqual(sql, "name != 'CSharps'")
23+
self.assertEqual(sql, "test_table.name != 'CSharps'")
2424

2525
def test_like(self):
26-
_where = name_column.like('Python%')
26+
_where = TestTable.name.like('Python%')
2727
sql = _where.__str__()
2828
print(sql)
29-
self.assertEqual(sql, "name LIKE 'Python%'")
29+
self.assertEqual(sql, "test_table.name LIKE 'Python%'")
3030

3131
def test_is_in(self):
32-
_where = name_column.is_in(['Pythonistas', 'Rustaceans'])
32+
_where = TestTable.name.is_in(['Pythonistas', 'Rustaceans'])
3333
sql = _where.__str__()
3434
print(sql)
35-
self.assertEqual(sql, "name IN ('Pythonistas', 'Rustaceans')")
35+
self.assertEqual(sql, "test_table.name IN ('Pythonistas', 'Rustaceans')")
3636

3737
def test_not_in(self):
38-
_where = name_column.not_in(['CSharps'])
38+
_where = TestTable.name.not_in(['CSharps'])
3939
sql = _where.__str__()
4040
print(sql)
41-
self.assertEqual(sql, "name NOT IN ('CSharps')")
41+
self.assertEqual(sql, "test_table.name NOT IN ('CSharps')")
4242

4343

4444
class TestWhere():

0 commit comments

Comments
 (0)