Skip to content

Commit 1cede2e

Browse files
committed
Enable runnable sample snippet tests
1 parent 3db2b49 commit 1cede2e

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

packages/bigframes/samples/snippets/samples_test.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
16+
1517
import pytest
1618

1719

18-
@pytest.mark.skip(reason="Documentation sample code snippet (b/522845525)")
1920
def test_query_standard_sql():
2021
# [START bigquery_bigframes_query]
2122
import bigframes.pandas as bpd
@@ -33,13 +34,17 @@ def test_query_standard_sql():
3334
df = bpd.read_gbq(sql)
3435

3536
# Run a query after explicitly specifying a project.
36-
bpd.options.bigquery.project = "your-project-id"
37+
project = "your-project-id"
38+
# [END bigquery_bigframes_query]
39+
project = os.environ.get("GOOGLE_CLOUD_PROJECT", "bigframes-dev-perf")
40+
bpd.close_session()
41+
# [START bigquery_bigframes_query]
42+
bpd.options.bigquery.project = project
3743
df = bpd.read_gbq(sql)
3844
# [END bigquery_bigframes_query]
39-
return df
45+
assert df is not None
4046

4147

42-
@pytest.mark.skip(reason="Documentation sample code snippet (b/522845525)")
4348
def test_query_legacy_sql():
4449
# [START bigquery_bigframes_query_legacy]
4550
import bigframes.pandas as bpd
@@ -57,10 +62,9 @@ def test_query_legacy_sql():
5762
query_config = {"query": {"useLegacySql": True}}
5863
df = bpd.read_gbq(sql, configuration=query_config)
5964
# [END bigquery_bigframes_query_legacy]
60-
return df
65+
assert df is not None
6166

6267

63-
@pytest.mark.skip(reason="Documentation sample code snippet (b/522845525)")
6468
def test_query_bqstorage():
6569
# [START bigquery_bigframes_query_bqstorage]
6670
import bigframes.pandas as bpd
@@ -81,10 +85,9 @@ def test_query_bqstorage():
8185
# automatically uses the BigQuery Storage API if installed.
8286
pandas_df = df.to_pandas()
8387
# [END bigquery_bigframes_query_bqstorage]
84-
return pandas_df
88+
assert pandas_df is not None
8589

8690

87-
@pytest.mark.skip(reason="Documentation sample code snippet (b/522845525)")
8891
def test_query_parameters():
8992
# [START bigquery_bigframes_query_parameters]
9093
import bigframes.pandas as bpd
@@ -113,10 +116,10 @@ def test_query_parameters():
113116

114117
df = bpd.read_gbq(sql, configuration=query_config)
115118
# [END bigquery_bigframes_query_parameters]
116-
return df
119+
assert df is not None
117120

118121

119-
@pytest.mark.skip(reason="Documentation sample code snippet (b/522845525)")
122+
@pytest.mark.skip(reason="Requires a writable table destination (b/522845525)")
120123
def test_upload_from_dataframe():
121124
# [START bigquery_bigframes_upload_from_dataframe]
122125
import pandas as pd

0 commit comments

Comments
 (0)