Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions bigquery/api/load_data_by_post_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2015, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import re

from nose.plugins.attrib import attr

import tests

from .load_data_by_post import load_data


@attr('slow')
class TestLoadDataByPost(tests.CloudBaseTest):
dataset_id = 'ephemeral_dataset'
table_id = 'load_data_by_post'

def test_load_csv_data(self):
schema_path = os.path.join(self.resource_path, 'schema.json')
data_path = os.path.join(self.resource_path, 'data.csv')
with tests.capture_stdout() as mock_stdout:
load_data(schema_path,
data_path,
self.project_id,
self.dataset_id,
self.table_id
)

stdout = mock_stdout.getvalue()

self.assertRegexpMatches(stdout, re.compile(
r'Waiting for job to finish.*Job complete.', re.DOTALL))

def test_load_json_data(self):
schema_path = os.path.join(self.resource_path, 'schema.json')
data_path = os.path.join(self.resource_path, 'data.json')

with tests.capture_stdout() as mock_stdout:
load_data(schema_path,
data_path,
self.project_id,
self.dataset_id,
self.table_id
)

stdout = mock_stdout.getvalue()

self.assertRegexpMatches(stdout, re.compile(
r'Waiting for job to finish.*Job complete.', re.DOTALL))
1 change: 1 addition & 0 deletions tests/resources/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Name": "Gandalf", "Age": 2000, "Weight": 140.0, "IsMagic": true}