Skip to content

Commit

Permalink
Remove cloud config fixture [(#887)](GoogleCloudPlatform/python-docs-…
Browse files Browse the repository at this point in the history
…samples#887)

* Remove cloud config fixture

* Fix client secrets

* Fix bigtable instance
  • Loading branch information
Jon Wayne Parrott authored and busunkim96 committed Sep 29, 2020
1 parent bdab179 commit b012988
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,47 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import snippets

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

def test_sentiment_text(cloud_config, capsys):

def test_sentiment_text(capsys):
snippets.sentiment_text('President Obama is speaking at the White House.')
out, _ = capsys.readouterr()
assert 'Score: 0.2' in out


def test_sentiment_file(cloud_config, capsys):
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
cloud_config.storage_bucket)
snippets.sentiment_file(cloud_storage_input_uri)
def test_sentiment_file(capsys):
snippets.sentiment_file(TEST_FILE_URL)
out, _ = capsys.readouterr()
assert 'Score: 0.2' in out


def test_entities_text(cloud_config, capsys):
def test_entities_text(capsys):
snippets.entities_text('President Obama is speaking at the White House.')
out, _ = capsys.readouterr()
assert 'name' in out
assert ': Obama' in out


def test_entities_file(cloud_config, capsys):
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
cloud_config.storage_bucket)
snippets.entities_file(cloud_storage_input_uri)
def test_entities_file(capsys):
snippets.entities_file(TEST_FILE_URL)
out, _ = capsys.readouterr()
assert 'name' in out
assert ': Obama' in out


def test_syntax_text(cloud_config, capsys):
def test_syntax_text(capsys):
snippets.syntax_text('President Obama is speaking at the White House.')
out, _ = capsys.readouterr()
assert 'NOUN: President' in out


def test_syntax_file(cloud_config, capsys):
cloud_storage_input_uri = 'gs://{}/text.txt'.format(
cloud_config.storage_bucket)
snippets.syntax_file(cloud_storage_input_uri)
def test_syntax_file(capsys):
snippets.syntax_file(TEST_FILE_URL)
out, _ = capsys.readouterr()
assert 'NOUN: President' in out
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for main."""

import os
import re
import zipfile

import main


_TEST_IMAGE_URI = 'gs://{}/language/image8.png'
BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
TEST_IMAGE_URI = 'gs://{}/language/image8.png'.format(BUCKET)


def test_batch_empty():
Expand All @@ -36,10 +35,10 @@ def test_batch_single():
assert batched == ((1,),)


def test_single_image_returns_text(cloud_config):
def test_single_image_returns_text():
vision_api_client = main.VisionApi()

image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket)
image_path = TEST_IMAGE_URI
texts = vision_api_client.detect_text([image_path])

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


def test_entities_list(cloud_config):
def test_entities_list():
vision_api_client = main.VisionApi()
image_path = _TEST_IMAGE_URI.format(cloud_config.storage_bucket)
image_path = TEST_IMAGE_URI
texts = vision_api_client.detect_text([image_path])
locale, document = main.extract_description(texts[image_path])
text_analyzer = main.TextAnalyzer()
Expand Down

0 comments on commit b012988

Please sign in to comment.