예제 #1
0
    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()
예제 #2
0
    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"}))
예제 #3
0
    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"}))
예제 #4
0
 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)
예제 #5
0
    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'}))
예제 #6
0
    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'}))
예제 #7
0
    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",
        )
예제 #8
0
    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')
예제 #9
0
    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()
예제 #10
0
    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()
예제 #11
0
    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'
        )