Skip to content

Commit b012988

Browse files
Jon Wayne Parrottbusunkim96
Jon Wayne Parrott
authored andcommitted
Remove cloud config fixture [(#887)](GoogleCloudPlatform/python-docs-samples#887)
* Remove cloud config fixture * Fix client secrets * Fix bigtable instance
1 parent bdab179 commit b012988

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

packages/google-cloud-language/samples/snippets/cloud-client/snippets_test.py

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

15+
import os
1516

1617
import snippets
1718

19+
BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
20+
TEST_FILE_URL = 'gs://{}/text.txt'.format(BUCKET)
1821

19-
def test_sentiment_text(cloud_config, capsys):
22+
23+
def test_sentiment_text(capsys):
2024
snippets.sentiment_text('President Obama is speaking at the White House.')
2125
out, _ = capsys.readouterr()
2226
assert 'Score: 0.2' in out
2327

2428

25-
def test_sentiment_file(cloud_config, capsys):
26-
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
27-
cloud_config.storage_bucket)
28-
snippets.sentiment_file(cloud_storage_input_uri)
29+
def test_sentiment_file(capsys):
30+
snippets.sentiment_file(TEST_FILE_URL)
2931
out, _ = capsys.readouterr()
3032
assert 'Score: 0.2' in out
3133

3234

33-
def test_entities_text(cloud_config, capsys):
35+
def test_entities_text(capsys):
3436
snippets.entities_text('President Obama is speaking at the White House.')
3537
out, _ = capsys.readouterr()
3638
assert 'name' in out
3739
assert ': Obama' in out
3840

3941

40-
def test_entities_file(cloud_config, capsys):
41-
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
42-
cloud_config.storage_bucket)
43-
snippets.entities_file(cloud_storage_input_uri)
42+
def test_entities_file(capsys):
43+
snippets.entities_file(TEST_FILE_URL)
4444
out, _ = capsys.readouterr()
4545
assert 'name' in out
4646
assert ': Obama' in out
4747

4848

49-
def test_syntax_text(cloud_config, capsys):
49+
def test_syntax_text(capsys):
5050
snippets.syntax_text('President Obama is speaking at the White House.')
5151
out, _ = capsys.readouterr()
5252
assert 'NOUN: President' in out
5353

5454

55-
def test_syntax_file(cloud_config, capsys):
56-
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
57-
cloud_config.storage_bucket)
58-
snippets.syntax_file(cloud_storage_input_uri)
55+
def test_syntax_file(capsys):
56+
snippets.syntax_file(TEST_FILE_URL)
5957
out, _ = capsys.readouterr()
6058
assert 'NOUN: President' in out

packages/google-cloud-language/samples/snippets/ocr_nl/main_test.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
"""Tests for main."""
17-
16+
import os
1817
import re
1918
import zipfile
2019

2120
import main
2221

23-
24-
_TEST_IMAGE_URI = 'gs://{}/language/image8.png'
22+
BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
23+
TEST_IMAGE_URI = 'gs://{}/language/image8.png'.format(BUCKET)
2524

2625

2726
def test_batch_empty():
@@ -36,10 +35,10 @@ def test_batch_single():
3635
assert batched == ((1,),)
3736

3837

39-
def test_single_image_returns_text(cloud_config):
38+
def test_single_image_returns_text():
4039
vision_api_client = main.VisionApi()
4140

42-
image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket)
41+
image_path = TEST_IMAGE_URI
4342
texts = vision_api_client.detect_text([image_path])
4443

4544
assert image_path in texts
@@ -66,9 +65,9 @@ def test_text_returns_entities():
6665
assert wurl == 'http://en.wikipedia.org/wiki/Sherlock_Holmes'
6766

6867

69-
def test_entities_list(cloud_config):
68+
def test_entities_list():
7069
vision_api_client = main.VisionApi()
71-
image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket)
70+
image_path = TEST_IMAGE_URI
7271
texts = vision_api_client.detect_text([image_path])
7372
locale, document = main.extract_description(texts[image_path])
7473
text_analyzer = main.TextAnalyzer()

0 commit comments

Comments
 (0)