def _assert_converts(self, python_type, sql_type): fake_mprows = _get_fake_mprows(python_type) filesystem_root = '/tmp' path = 'temp.mpr' with patch.object(MPRowsFile, 'reader', new_callable=PropertyMock) as fake_reader: fake_reader.return_value = fake_mprows.reader mod = _get_module_instance() query, table = mod.Create('db', 'modulename', 'dbname', 'table1', filesystem_root, path) self.assertIn(sql_type, query)
def test_raises_exception_if_type_conversion_failed(self): fake_mprows = _get_fake_mprows('unknown') mod = _get_module_instance() filesystem_root = '/tmp' path = 'temp.mpr' with patch.object(MPRowsFile, 'reader', new_callable=PropertyMock) as fake_reader: fake_reader.return_value = fake_mprows.reader try: mod.Create('db', 'modulename', 'dbname', 'table1', filesystem_root, path) except Exception as exc: self.assertIn('Do not know how to convert', str(exc))
def test_returns_create_table_query_and_table(self): fake_mprows = _get_fake_mprows('int') filesystem_root = '/tmp' path = 'temp.mpr' with patch.object(MPRowsFile, 'reader', new_callable=PropertyMock) as fake_reader: fake_reader.return_value = fake_mprows.reader mod = _get_module_instance() ret = mod.Create('db', 'modulename', 'dbname', 'table1', filesystem_root, path) self.assertEqual(len(ret), 2) query, table = ret self.assertEqual('CREATE TABLE table1("column1" INTEGER);', query) self.assertTrue(hasattr(table, 'Open'))
def test_returns_source_class(self): mod = _get_module_instance() self.assertTrue(hasattr(mod, 'Create')) self.assertTrue(six.callable(mod.Create))