def aiotest(): from aiorm import registry from aiorm.orm import Transaction from aiorm.orm import interfaces yield from registry.connect('/sample') cursor = registry.get(interfaces.IDialect)() cursor.configure_mock(**{'render_begin_transaction.return_value': 'begin_transaction'}) transaction = Transaction('sample') yield from transaction.begin() cursor.render_begin_transaction.assert_called_once_with() self.assertEqual(driver.DummyCursor.last_query, 'begin_transaction') yield from registry.disconnect('sample')
def aiotest(): from aiorm import registry from aiorm.orm import Transaction from aiorm.orm import interfaces yield from registry.connect('/sample') cursor = registry.get(interfaces.IDialect)() cursor.configure_mock( ** {'render_begin_transaction.return_value': 'begin_transaction'}) transaction = Transaction('sample') yield from transaction.begin() cursor.render_begin_transaction.assert_called_once_with() self.assertEqual(driver.DummyCursor.last_query, 'begin_transaction') yield from registry.disconnect('sample')
def aiotest(): from aiorm import registry from aiorm.orm import Transaction yield from registry.connect('/sample') transaction = Transaction('sample') self.assertIsInstance(transaction.driver, driver.DummyDriver) self.assertEqual(transaction.driver.database, 'sample') yield from registry.disconnect('sample')
def aiotest(): from aiorm import registry from aiorm.orm import Transaction from aiorm.orm import interfaces yield from registry.connect('/sample') driver.DummyCursor.return_many = [[('one', ), ('two', )]] transaction = yield from Transaction('sample').begin() result = yield from transaction.fetchall() self.assertEqual(result, [('one', ), ('two', )]) yield from registry.disconnect('sample')
def aiotest(): from aiorm import registry from aiorm.orm import Transaction from aiorm.orm import interfaces yield from registry.connect('/sample') driver.DummyCursor.return_one = ['one'] transaction = yield from Transaction('sample').begin() result = yield from transaction.fetchone() self.assertEqual(result, 'one') yield from registry.disconnect('sample')
def aiotest(): from aiorm import registry from aiorm.orm import Transaction from aiorm.orm import interfaces yield from registry.connect('/sample') transaction = yield from Transaction('sample').begin() yield from transaction.execute('dummy_query') self.assertEqual(driver.DummyCursor.last_query, 'dummy_query') yield from registry.disconnect('sample')