def test_client_sets_user_agent(project_id, monkeypatch): mock_client = mock.create_autospec(bq.Client) monkeypatch.setattr(bq, 'Client', mock_client) connect( project_id, dataset_id='bigquery-public-data.stackoverflow', application_name='my-great-app/0.7.0', ) info = mock_client.call_args[1]['client_info'] user_agent = info.to_user_agent() assert ' ibis/{}'.format(ibis.__version__) in user_agent assert 'my-great-app/0.7.0 ' in user_agent
def connect(data_directory: Path) -> ibis.client.Client: from ibis.bigquery.tests.conftest import connect project_id = os.environ.get('GOOGLE_BIGQUERY_PROJECT_ID') if project_id is None: pytest.skip('Environment variable GOOGLE_BIGQUERY_PROJECT_ID ' 'not defined') elif not project_id: pytest.skip( 'Environment variable GOOGLE_BIGQUERY_PROJECT_ID is empty') return connect(project_id, dataset_id='testing')
def client(): from ibis.bigquery.tests.conftest import connect return connect(PROJECT_ID, DATASET_ID)
def test_client_without_dataset(project_id): con = connect(project_id, dataset_id=None) with pytest.raises(ValueError, match="Unable to determine BigQuery"): con.list_tables()
def test_repeated_project_name(project_id): con = connect(project_id, dataset_id='{}.testing'.format(project_id)) assert 'functional_alltypes' in con.list_tables()