Skip to content

Commit 2da1f53

Browse files
authored
Making bigtable tests run successfully [(#1764)](GoogleCloudPlatform/python-docs-samples#1764)
* Making bigtable tests run successfully * Fixed missing import * Renamed noxfile for new environment * Moving the nox name back
1 parent 6dfec67 commit 2da1f53

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

samples/tableadmin/tableadmin.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
from google.cloud.bigtable import column_family
3838

3939

40-
def run_table_operations(project_id, instance_id, table_id):
41-
''' Create a Bigtable table and perform basic table operations
40+
def create_table(project_id, instance_id, table_id):
41+
''' Create a Bigtable table
4242
4343
:type project_id: str
4444
:param project_id: Project id of the client.
@@ -64,6 +64,24 @@ def run_table_operations(project_id, instance_id, table_id):
6464
table.create()
6565
print('Created table {}.'.format(table_id))
6666

67+
return client, instance, table
68+
69+
70+
def run_table_operations(project_id, instance_id, table_id):
71+
''' Create a Bigtable table and perform basic operations on it
72+
73+
:type project_id: str
74+
:param project_id: Project id of the client.
75+
76+
:type instance_id: str
77+
:param instance_id: Instance of the client.
78+
79+
:type table_id: str
80+
:param table_id: Table id to create table.
81+
'''
82+
83+
client, instance, table = create_table(project_id, instance_id, table_id)
84+
6785
# [START bigtable_list_tables]
6886
tables = instance.list_tables()
6987
print('Listing tables in current project...')

samples/tableadmin/tableadmin_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717
import random
1818

19+
from tableadmin import create_table
1920
from tableadmin import delete_table
2021
from tableadmin import run_table_operations
2122

@@ -53,6 +54,7 @@ def test_run_table_operations(capsys):
5354
def test_delete_table(capsys):
5455
table_name = TABLE_NAME_FORMAT.format(
5556
random.randrange(TABLE_NAME_RANGE))
57+
create_table(PROJECT, BIGTABLE_CLUSTER, table_name)
5658

5759
delete_table(PROJECT, BIGTABLE_CLUSTER, table_name)
5860
out, _ = capsys.readouterr()

0 commit comments

Comments
 (0)