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

Method test_get_prefetch

tests/table/test_objects.py:75–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 self.assertEqual(band.name, "Pythonistas")
74
75 def test_get_prefetch(self):
76 self.insert_rows()
77
78 # With prefetch clause
79 band = (
80 Band.objects()
81 .get((Band.name == "Pythonistas"))
82 .prefetch(Band.manager)
83 .run_sync()
84 )
85 assert band is not None
86 self.assertIsInstance(band.manager, Manager) # type: ignore
87
88 # Just passing it straight into objects
89 band = (
90 Band.objects(Band.manager)
91 .get((Band.name == "Pythonistas"))
92 .run_sync()
93 )
94 assert band is not None
95 self.assertIsInstance(band.manager, Manager)
96
97
98class TestGetOrCreate(DBTestCase):

Callers

nothing calls this directly

Calls 5

getMethod · 0.80
objectsMethod · 0.80
insert_rowsMethod · 0.45
run_syncMethod · 0.45
prefetchMethod · 0.45

Tested by

no test coverage detected