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

Method run_nested

tests/engine/test_nested_transaction.py:33–54  ·  view source on GitHub ↗

Make sure nested transactions which reference different databases work as expected.

(self)

Source from the content-addressed store, hash-verified

31 ENGINE_2.remove_db_file()
32
33 async def run_nested(self):
34 """
35 Make sure nested transactions which reference different databases work
36 as expected.
37 """
38 async with Musician._meta.db.transaction():
39 await Musician.create_table().run()
40 await Musician(name="Bob").save().run()
41
42 async with Roadie._meta.db.transaction():
43 await Roadie.create_table().run()
44 await Roadie(name="Dave").save().run()
45
46 self.assertTrue(await Musician.table_exists().run())
47 musician = await Musician.select("name").first().run()
48 assert musician is not None
49 self.assertEqual(musician["name"], "Bob")
50
51 self.assertTrue(await Roadie.table_exists().run())
52 roadie = await Roadie.select("name").first().run()
53 assert roadie is not None
54 self.assertEqual(roadie["name"], "Dave")
55
56 def test_nested(self):
57 asyncio.run(self.run_nested())

Callers 1

test_nestedMethod · 0.95

Calls 11

RoadieClass · 0.85
create_tableMethod · 0.80
saveMethod · 0.80
assertTrueMethod · 0.80
selectMethod · 0.80
assertEqualMethod · 0.80
MusicianClass · 0.70
transactionMethod · 0.45
runMethod · 0.45
table_existsMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected