Skip to content

Commit 3fdfd85

Browse files
committed
changing tests to use manager instead of trainer example
1 parent c1fd0ae commit 3fdfd85

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed

docs/src/piccolo/transactions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Usage
1212
.. code-block:: python
1313
1414
transaction = Band.Meta.db.transaction()
15-
transaction.add(Trainer.create())
15+
transaction.add(Manager.create())
1616
transaction.add(Match.create())
1717
await transaction.run()

piccolo/columns/column_types.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class ForeignKey(Integer):
7575
7676
http://www.postgresqltutorial.com/postgresql-foreign-key/
7777
78-
some_band.trainer
78+
some_band.manager
7979
>>> 1
80-
Band.select('name', 'trainer.name')
80+
Band.select('name', 'manager.name')
8181
8282
I'm not sure about explicit joins ... only useful if we want to specify
8383
inner and outer joins.
@@ -86,21 +86,21 @@ class ForeignKey(Integer):
8686
8787
To get the actual User object.
8888
89-
User.object().where(User.id == some_band.trainer)
89+
User.object().where(User.id == some_band.manager)
9090
9191
OR
9292
93-
some_band.related_object('trainer')
93+
some_band.related_object('manager')
9494
> is just a proxy to the above
9595
9696
class Band(Table):
97-
trainer = ForeignKey(User)
97+
manager = ForeignKey(User)
9898
99-
To change the trainer:
100-
some_band.trainer = some_trainer_id
99+
To change the manager:
100+
some_band.manager = some_manager_id
101101
some_band.save()
102102
Or:
103-
some_band.set_related_object('trainer', some_trainer)
103+
some_band.set_related_object('manager', some_manager)
104104
105105
"""
106106

piccolo/table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def remove(self):
120120

121121
def get_related(self, column_name: str):
122122
"""
123-
some_band.get_related('trainer')
123+
some_band.get_related('manager')
124124
"""
125125
cls = self.__class__
126126

@@ -166,7 +166,7 @@ def ref(
166166
"""
167167
Used to get a copy of a column in a reference table.
168168
169-
Example: trainer.name
169+
Example: manager.name
170170
"""
171171
local_column_name, reference_column_name = column_name.split('.')
172172

@@ -205,7 +205,7 @@ def select(cls, *column_names: str) -> Select:
205205
def insert(cls, *rows: 'Table') -> Insert:
206206
"""
207207
await Band.insert(
208-
Band(name="jigglypuff", power=500, trainer="florence")
208+
Band(name="jigglypuff", power=500, manager="florence")
209209
).run()
210210
"""
211211
query = Insert(

tests/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def create_table(self):
2121
CREATE TABLE band (
2222
id SERIAL PRIMARY KEY,
2323
name VARCHAR(50),
24-
trainer VARCHAR(20),
24+
manager VARCHAR(20),
2525
power SMALLINT
2626
);''')
2727

2828
def insert_row(self):
2929
self.run_sync('''
3030
INSERT INTO band (
3131
name,
32-
trainer,
32+
manager,
3333
power
3434
) VALUES (
3535
'pikachu',
@@ -41,7 +41,7 @@ def insert_rows(self):
4141
self.run_sync('''
4242
INSERT INTO band (
4343
name,
44-
trainer,
44+
manager,
4545
power
4646
) VALUES (
4747
'pikachu',

tests/engine/test_transaction.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest import TestCase
22

3-
from ..example_project.tables import Band, Trainer
3+
from ..example_project.tables import Band, Manager
44

55

66
class TestTransaction(TestCase):
@@ -12,37 +12,37 @@ def test_error(self):
1212
transaction = Band.Meta.db.transaction()
1313
transaction.add(
1414
Band.create(),
15-
Trainer.create(),
15+
Manager.create(),
1616
Band.raw('MALFORMED QUERY ... SHOULD ERROR')
1717
)
1818
try:
1919
transaction.run_sync()
20-
except Exception as error:
20+
except Exception:
2121
pass
2222
self.assertTrue(
2323
not Band.table_exists().run_sync()
2424
)
2525
self.assertTrue(
26-
not Trainer.table_exists().run_sync()
26+
not Manager.table_exists().run_sync()
2727
)
2828

2929
def test_succeeds(self):
3030
transaction = Band.Meta.db.transaction()
3131
transaction.add(
3232
Band.create(),
33-
Trainer.create()
33+
Manager.create()
3434
)
3535
transaction.run_sync()
3636

3737
self.assertTrue(
3838
Band.table_exists().run_sync()
3939
)
4040
self.assertTrue(
41-
Trainer.table_exists().run_sync()
41+
Manager.table_exists().run_sync()
4242
)
4343

4444
transaction.add(
4545
Band.drop(),
46-
Trainer.drop()
46+
Manager.drop()
4747
)
4848
transaction.run_sync()

tests/example_project/tables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
class Band(table.Table):
1818
name = columns.Varchar(length=50)
19-
trainer = columns.Varchar(length=20)
19+
manager = columns.Varchar(length=20)
2020
power = columns.Integer()
2121

2222
class Meta():
2323
db = DB
2424

2525

26-
class Trainer(table.Table):
26+
class Manager(table.Table):
2727
name = columns.Varchar(length=50)
2828

2929
class Meta():

tests/table/instance/test_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_delete(self):
1414

1515
squirtle = Band(
1616
name='squirtle',
17-
trainer='Misty',
17+
manager='Misty',
1818
power=300
1919
)
2020

tests/table/instance/test_save.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_save_new(self):
1818

1919
squirtle = Band(
2020
name='squirtle',
21-
trainer='Misty',
21+
manager='Misty',
2222
power=300
2323
)
2424

tests/table/test_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_create_table(self):
1515

1616
# Just do a count to make sure the table was created ok.
1717
response = Band.select(
18-
'name', 'trainer', 'power'
18+
'name', 'manager', 'power'
1919
).count().run_sync()
2020

2121
self.assertEqual(response[0]['count'], 0)

tests/table/test_insert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ..base import DBTestCase
2-
from ..example_project.tables import Band, Trainer
2+
from ..example_project.tables import Band, Manager
33

44

55
class TestInsert(DBTestCase):
@@ -38,5 +38,5 @@ def test_incompatible_type(self):
3838
"""
3939
with self.assertRaises(TypeError):
4040
Band.insert().add(
41-
Trainer(name="Ash")
41+
Manager(name="Ash")
4242
).run_sync()

0 commit comments

Comments
 (0)