MCPcopy Index your code
hub / github.com/piccolo-orm/piccolo / test_joins

Method test_joins

tests/table/test_objects.py:196–214  ·  view source on GitHub ↗

Make sure that that `get_or_create` creates rows correctly when using joins.

(self)

Source from the content-addressed store, hash-verified

194 self.assertEqual(instance.popularity, 0)
195
196 def test_joins(self):
197 """
198 Make sure that that `get_or_create` creates rows correctly when using
199 joins.
200 """
201 instance = (
202 Band.objects()
203 .get_or_create(
204 (Band.name == "My new band")
205 & (Band.manager.name == "Excellent manager")
206 )
207 .run_sync()
208 )
209 self.assertIsInstance(instance, Band)
210 self.assertEqual(instance._was_created, True)
211
212 # We want to make sure the band name isn't 'Excellent manager' by
213 # mistake.
214 self.assertEqual(Band.name, "My new band")
215
216 def test_prefetch_existing_object(self):
217 """

Callers

nothing calls this directly

Calls 4

get_or_createMethod · 0.80
objectsMethod · 0.80
assertEqualMethod · 0.80
run_syncMethod · 0.45

Tested by

no test coverage detected