Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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))
Пример #4
0
 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'))
Пример #5
0
 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))
Пример #6
0
 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'))
Пример #7
0
 def test_returns_source_class(self):
     mod = _get_module_instance()
     self.assertTrue(hasattr(mod, 'Create'))
     self.assertTrue(six.callable(mod.Create))
Пример #8
0
 def test_returns_source_class(self):
     mod = _get_module_instance()
     self.assertTrue(hasattr(mod, 'Create'))
     self.assertTrue(six.callable(mod.Create))