33from ..example_project .tables import Pokemon , Stadium , Match
44
55
6- class TestCreateJoin (TestCase ):
6+ # class TestCreateJoin():
77
8- def test_create_join (self ):
8+ # def test_create_join(self):
99
10- # Pokemon.create().run_sync()
11- # Stadium.create().run_sync()
12- Match .create ().run_sync ()
10+ # Pokemon.create().run_sync()
11+ # Stadium.create().run_sync()
12+ # Match.create().run_sync()
1313
14- Match .delete ().run_sync ()
15- Pokemon .delete ().run_sync ()
16- Stadium .delete ().run_sync ()
14+ # Match.drop ().run_sync()
15+ # Pokemon.drop ().run_sync()
16+ # Stadium.drop ().run_sync()
1717
1818
19- # TODO - PUT BACK
20- class _TestJoin (TestCase ):
19+ class TestJoin (TestCase ):
2120 """
2221 Test instantiating Table instances
2322 """
@@ -28,41 +27,42 @@ def setUp(self):
2827 Match .create ().run_sync ()
2928
3029 def tearDown (self ):
31- Match .delete ().run_sync ()
32- Pokemon .delete ().run_sync ()
33- Stadium .delete ().run_sync ()
34-
35- def _test_join (self ):
36- """
37- Need a good example ...
38- """
39- try :
40- pikachu = Pokemon (name = "pikachu" )
41- pikachu .save ().run_sync ()
42-
43- bulbasaur = Pokemon (name = "bulbasaur" )
44- bulbasaur .save ().run_sync ()
45-
46- stadium = Stadium (name = "fairy garden" )
47-
48- Match (
49- pokemon1 = pikachu ,
50- pokemon2 = bulbasaur ,
51- stadium = stadium
52- ).save ().run_sync ()
53-
54- response = Match .select (
55- 'pokemon1.name' ,
56- 'pokemon2.name' ,
57- 'stadium.name'
58- ).run_sync ()
59- except Exception :
60- pass
61-
62- def test_ref (self ):
63- """
64- Match.select().count().where(
65- Match.ref('pokemon1.name') == 'pikachu'
30+ Match .drop ().run_sync ()
31+ Pokemon .drop ().run_sync ()
32+ Stadium .drop ().run_sync ()
33+
34+ def test_join (self ):
35+ pikachu = Pokemon (name = "pikachu" , trainer = "ash" )
36+ pikachu .save ().run_sync ()
37+
38+ bulbasaur = Pokemon (name = "bulbasaur" )
39+ bulbasaur .save ().run_sync ()
40+
41+ stadium = Stadium (name = "fairy garden" )
42+ stadium .save ().run_sync ()
43+
44+ # TODO - make sure you can also do:
45+ # pokemon_1=pikachu
46+ save_query = Match (
47+ pokemon_1 = pikachu .id ,
48+ pokemon_2 = bulbasaur .id ,
49+ stadium = stadium .id
50+ ).save ()
51+ save_query .run_sync ()
52+
53+ select_query = Match .select (
54+ 'pokemon_1.name' ,
55+ 'pokemon_2.name' ,
56+ 'stadium.name' ,
57+ 'pokemon_1.trainer'
6658 )
67- """
68- pass
59+ response = select_query .run_sync ()
60+ import ipdb ; ipdb .set_trace ()
61+
62+ # def _test_ref(self):
63+ # """
64+ # Match.select().count().where(
65+ # Match.ref('pokemon1.name') == 'pikachu'
66+ # )
67+ # """
68+ # pass
0 commit comments