def test_write_local_data_files():

        # Configure
        task_id = "some_test_id"
        sql = "some_sql"
        bucket = "some_bucket"
        filename = "some_filename"
        row_iter = [[1, b'byte_str_1'], [2, b'byte_str_2']]
        schema = [{
            'name': 'location',
            'type': 'STRING',
            'mode': 'nullable',
        }, {
            'name': 'uuid',
            'type': 'BYTES',
            'mode': 'nullable',
        }]
        schema_str = json.dumps(schema)

        op = MySqlToGoogleCloudStorageOperator(
            task_id=task_id,
            sql=sql,
            bucket=bucket,
            filename=filename,
            schema=schema_str)

        cursor_mock = MagicMock()
        cursor_mock.__iter__.return_value = row_iter

        # Run
        op._write_local_data_files(cursor_mock)
Exemplo n.º 2
0
    def test_write_local_data_files():

        # Configure
        task_id = "some_test_id"
        sql = "some_sql"
        bucket = "some_bucket"
        filename = "some_filename"
        row_iter = [[1, b'byte_str_1'], [2, b'byte_str_2']]
        schema = [{
            'name': 'location',
            'type': 'STRING',
            'mode': 'nullable',
        }, {
            'name': 'uuid',
            'type': 'BYTES',
            'mode': 'nullable',
        }]
        schema_str = json.dumps(schema)

        op = MySqlToGoogleCloudStorageOperator(task_id=task_id,
                                               sql=sql,
                                               bucket=bucket,
                                               filename=filename,
                                               schema=schema_str)

        cursor_mock = MagicMock()
        cursor_mock.__iter__.return_value = row_iter

        # Run
        op._write_local_data_files(cursor_mock)
Exemplo n.º 3
0
    def test_write_local_data_files(self):

        # Configure
        task_id = "some_test_id"
        sql = "some_sql"
        bucket = "some_bucket"
        filename = "some_filename"
        schema = "some_schema"
        description_list = [['col_integer'], ['col_byte']]
        row_iter = [[1, b'byte_str_1'], [2, b'byte_str_2']]

        op = MySqlToGoogleCloudStorageOperator(task_id=task_id,
                                               sql=sql,
                                               bucket=bucket,
                                               filename=filename,
                                               schema=schema)

        cursor_mock = MagicMock()
        cursor_mock.description = description_list
        cursor_mock.__iter__.return_value = row_iter

        # Run
        op._write_local_data_files(cursor_mock)
    def test_write_local_data_files(self):

        # Configure
        task_id = "some_test_id"
        sql = "some_sql"
        bucket = "some_bucket"
        filename = "some_filename"
        schema = "some_schema"
        description_list = [['col_integer'], ['col_byte']]
        row_iter = [[1, b'byte_str_1'], [2, b'byte_str_2']]

        op = MySqlToGoogleCloudStorageOperator(
            task_id=task_id,
            sql=sql,
            bucket=bucket,
            filename=filename,
            schema=schema)

        cursor_mock = MagicMock()
        cursor_mock.description = description_list
        cursor_mock.__iter__.return_value = row_iter

        # Run
        op._write_local_data_files(cursor_mock)