Ejemplo n.º 1
0
 async def _setUpDB(self):
     self.db = await self.getDB()
     if not _Tortoise._inited:
         _Tortoise.init(self.db)
     else:
         _Tortoise._client_routing(self.db)
     await _generate_schema(self.db)
Ejemplo n.º 2
0
 def test_missing_app_route2(self):
     Tortoise.apps = self.apps
     with self.assertRaisesRegex(ConfigurationError,
                                 'All app values must inherit from BaseDBAsyncClient'):
         Tortoise._client_routing(db_routing={
             'models': 'moo',
         })
Ejemplo n.º 3
0
    async def setUp(self):
        self.db = await self.getDB()
        self.second_db = await self.getDB()
        Tortoise._client_routing(db_routing={
            'models': self.db,
            'events': self.second_db,
        })

        if not Tortoise._inited:
            Tortoise._init_relations()

        await generate_schema(self.db)
        await generate_schema(self.second_db)
Ejemplo n.º 4
0
 def test_missing_param(self):
     with self.assertRaisesRegex(ConfigurationError,
                                 'You must pass either global_client or db_routing'):
         Tortoise._client_routing()
Ejemplo n.º 5
0
 def test_not_db(self):
     with self.assertRaisesRegex(ConfigurationError,
                                 'global_client must inherit from BaseDBAsyncClient'):
         Tortoise._client_routing(global_client='moo')
Ejemplo n.º 6
0
 def test_exclusive_route_param(self):
     with self.assertRaisesRegex(ConfigurationError, 'You must pass either'):
         Tortoise._client_routing(db_routing={
             'models': self.db,
         }, global_client=self.db)
Ejemplo n.º 7
0
 def test_missing_app_route(self):
     Tortoise.apps = self.apps
     with self.assertRaisesRegex(ConfigurationError, 'No db instanced for apps'):
         Tortoise._client_routing(db_routing={
             'models': self.db,
         })