def test_get_batch_source_path_exists_true(self, get_connection): """ Test :py:meth:`.BaseImporter.get_batch_source_path_exists`. This tests the case of ``True``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ['test/path'] self.assertTrue( BaseImporter.get_batch_source_path_exists( 'test/path', odbc_kwargs={'dsn': 'TestDSN'}) ) get_connection.assert_called_once_with(dsn='TestDSN') connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( 'SELECT batch_source_path FROM meta.batch_history ' 'WHERE batch_source_name = ? AND batch_source_type_name = ? AND ' 'batch_source_path = ? LIMIT 1', 'test_bsn', 'ga3', 'test/path' ) cursor.fetchone.assert_called_once_with()
def test_get_last_imported_batch_source_path_none(self, get_connection): """ Test :py:meth:`.BaseImporter.get_last_imported_batch_source_path`. This tests the case of returning ``None``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = None self.assertEqual(None, BaseImporter.get_last_imported_batch_source_path(odbc_kwargs={"dsn": "TestDSN"}))
def test_get_batch_source_path_exists_false(self, get_connection): """ Test :py:meth:`.BaseImporter.get_batch_source_path_exists`. This tests the case of ``False``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = None self.assertFalse(BaseImporter.get_batch_source_path_exists("test/path", odbc_kwargs={"dsn": "TestDSN"}))
def get_importer(self, **kwargs): arguments = { 'reader_obj': Mock(), 'odbc_kwargs': { 'dsn': 'TestDSN' }, 'schema_name': 'schema', 'batch_source_path': 'test/path', } arguments.update(kwargs) return BaseImporter(**arguments)
def test_get_batch_source_path_exists_false(self, get_connection): """ Test :py:meth:`.BaseImporter.get_batch_source_path_exists`. This tests the case of ``False``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = None self.assertFalse( BaseImporter.get_batch_source_path_exists( 'test/path', odbc_kwargs={'dsn': 'TestDSN'}))
def test_get_last_imported_batch_source_path_none(self, get_connection): """ Test :py:meth:`.BaseImporter.get_last_imported_batch_source_path`. This tests the case of returning ``None``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = None self.assertEqual( None, BaseImporter.get_last_imported_batch_source_path( odbc_kwargs={'dsn': 'TestDSN'}))
def test_get_last_imported_batch_source_path(self, get_connection): """ Test :py:meth:`.BaseImporter.get_last_imported_batch_souce_path`. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ("foo/bar",) self.assertEqual("foo/bar", BaseImporter.get_last_imported_batch_source_path(odbc_kwargs={"dsn": "TestDSN"})) get_connection.assert_called_once_with(dsn="TestDSN") connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( "SELECT batch_source_path FROM meta.batch_history " "WHERE batch_source_name = ? AND batch_source_type_name = ? " "ORDER BY batch_import_timestamp DESC LIMIT 1", "test_bsn", "ga3", )
def test_get_last_imported_batch_source_path(self, get_connection): """ Test :py:meth:`.BaseImporter.get_last_imported_batch_souce_path`. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ('foo/bar', ) self.assertEqual( 'foo/bar', BaseImporter.get_last_imported_batch_source_path( odbc_kwargs={'dsn': 'TestDSN'})) get_connection.assert_called_once_with(dsn='TestDSN') connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( 'SELECT batch_source_path FROM meta.batch_history ' 'WHERE batch_source_name = ? AND batch_source_type_name = ? ' 'ORDER BY batch_import_timestamp DESC LIMIT 1', 'test_bsn', 'ga3')
def test_get_batch_source_path_exists_true(self, get_connection): """ Test :py:meth:`.BaseImporter.get_batch_source_path_exists`. This tests the case of ``True``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ['test/path'] self.assertTrue( BaseImporter.get_batch_source_path_exists( 'test/path', odbc_kwargs={'dsn': 'TestDSN'})) get_connection.assert_called_once_with(dsn='TestDSN') connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( 'SELECT batch_source_path FROM meta.batch_history ' 'WHERE batch_source_name = ? AND batch_source_type_name = ? AND ' 'batch_source_path = ? LIMIT 1', 'test_bsn', 'ga3', 'test/path') cursor.fetchone.assert_called_once_with()
def test_get_batch_source_path_exists_true(self, get_connection): """ Test :py:meth:`.BaseImporter.get_batch_source_path_exists`. This tests the case of ``True``. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ["test/path"] self.assertTrue(BaseImporter.get_batch_source_path_exists("test/path", odbc_kwargs={"dsn": "TestDSN"})) get_connection.assert_called_once_with(dsn="TestDSN") connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( "SELECT batch_source_path FROM meta.batch_history " "WHERE batch_source_name = ? AND batch_source_type_name = ? AND " "batch_source_path = ? LIMIT 1", "test_bsn", "ga3", "test/path", ) cursor.fetchone.assert_called_once_with()
def test_get_last_imported_batch_source_path(self, get_connection): """ Test :py:meth:`.BaseImporter.get_last_imported_batch_souce_path`. """ connection = get_connection.return_value cursor = connection.cursor.return_value cursor.fetchone.return_value = ('foo/bar',) self.assertEqual( 'foo/bar', BaseImporter.get_last_imported_batch_source_path( odbc_kwargs={'dsn': 'TestDSN'}) ) get_connection.assert_called_once_with(dsn='TestDSN') connection.cursor.assert_called_once_with() cursor.execute.assert_called_once_with( 'SELECT batch_source_path FROM meta.batch_history ' 'WHERE batch_source_name = ? AND batch_source_type_name = ? ' 'ORDER BY batch_import_timestamp DESC LIMIT 1', 'test_bsn', 'ga3' )