Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigQuery: 'test_bigquery_magic_w_maximum_bytes_billed_invalid' test uses real client. #8719

Closed
tseaver opened this issue Jul 19, 2019 · 0 comments · Fixed by #8727
Closed
Assignees
Labels
api: bigquery Issues related to the BigQuery API. testing type: process A process-related concern. May include testing, release, or the like.

Comments

@tseaver
Copy link
Contributor

tseaver commented Jul 19, 2019

The unit test fails if there are no valid credentials in the environment:

______________ test_bigquery_magic_w_maximum_bytes_billed_invalid ______________

    @pytest.mark.usefixtures("ipython_interactive")
    def test_bigquery_magic_w_maximum_bytes_billed_invalid():
        ip = IPython.get_ipython()
        ip.extension_manager.load_extension("google.cloud.bigquery")
        magics.context._project = None
    
        sql = "SELECT 17 AS num"
    
        with pytest.raises(ValueError):
>           ip.run_cell_magic("bigquery", "--maximum_bytes_billed=abc", sql)

tests/unit/test_magics.py:565: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.nox/unit-3-6/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2358: in run_cell_magic
    result = fn(*args, **kwargs)
google/cloud/bigquery/magics.py:400: in _cell_magic
    default_query_job_config=context.default_query_job_config,
google/cloud/bigquery/client.py:167: in __init__
    project=project, credentials=credentials, _http=_http
../core/google/cloud/client.py:226: in __init__
    _ClientProjectMixin.__init__(self, project=project)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <google.cloud.bigquery.client.Client object at 0x7f4bb6739d68>
project = None

    def __init__(self, project=None):
        project = self._determine_default(project)
        if project is None:
            raise EnvironmentError(
>               "Project was not passed and could not be "
                "determined from the environment."
            )
E           OSError: Project was not passed and could not be determined from the environment.

We want unit tests to run in complete isolation from any possibility of triggering real API requests. This test actually expects to run a real query, which means it is a system test.

@tseaver tseaver added testing api: bigquery Issues related to the BigQuery API. type: process A process-related concern. May include testing, release, or the like. labels Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. testing type: process A process-related concern. May include testing, release, or the like.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants