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 dpebot committed Apr 4, 2017
1 parent 2a65925 commit a1897d4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 47 deletions.
4 changes: 2 additions & 2 deletions samples/snippets/crop_hints/crop_hints_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import crop_hints


def test_crop(cloud_config, capsys):
def test_crop(capsys):
"""Checks the output image for cropping the image is created."""
file_name = os.path.join(
os.path.dirname(__file__),
Expand All @@ -27,7 +27,7 @@ def test_crop(cloud_config, capsys):
assert os.path.isfile('output-crop.jpg')


def test_draw(cloud_config, capsys):
def test_draw(capsys):
"""Checks the output image for drawing the crop hint is created."""
file_name = os.path.join(
os.path.dirname(__file__),
Expand Down
72 changes: 32 additions & 40 deletions samples/snippets/detect/detect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

import detect

BUCKET = os.environ['CLOUD_STORAGE_BUCKET']

def test_labels(cloud_config, capsys):

def test_labels(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/wakeupcat.jpg')
Expand All @@ -26,15 +28,14 @@ def test_labels(cloud_config, capsys):
assert 'Labels' in out


def test_labels_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/wakeupcat.jpg'.format(
cloud_config.storage_bucket))
def test_labels_uri(capsys):
file_name = 'gs://{}/vision/wakeupcat.jpg'.format(BUCKET)
detect.detect_labels_uri(file_name)
out, _ = capsys.readouterr()
assert 'Labels' in out


def test_landmarks(cloud_config, capsys):
def test_landmarks(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/landmark.jpg')
Expand All @@ -43,15 +44,14 @@ def test_landmarks(cloud_config, capsys):
assert 'Palace' in out


def test_landmarks_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/landmark.jpg'.format(
cloud_config.storage_bucket))
def test_landmarks_uri(capsys):
file_name = 'gs://{}/vision/landmark.jpg'.format(BUCKET)
detect.detect_landmarks_uri(file_name)
out, _ = capsys.readouterr()
assert 'Palace' in out


def test_faces(cloud_config, capsys):
def test_faces(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/face_no_surprise.jpg')
Expand All @@ -60,15 +60,14 @@ def test_faces(cloud_config, capsys):
assert 'Likelihood.POSSIBLE' in out


def test_faces_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/face_no_surprise.jpg'.format(
cloud_config.storage_bucket))
def test_faces_uri(capsys):
file_name = 'gs://{}/vision/face_no_surprise.jpg'.format(BUCKET)
detect.detect_faces_uri(file_name)
out, _ = capsys.readouterr()
assert 'Likelihood.POSSIBLE' in out


def test_logos(cloud_config, capsys):
def test_logos(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/logos.png')
Expand All @@ -77,15 +76,14 @@ def test_logos(cloud_config, capsys):
assert 'Google' in out


def test_logos_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/logos.png'.format(
cloud_config.storage_bucket))
def test_logos_uri(capsys):
file_name = 'gs://{}/vision/logos.png'.format(BUCKET)
detect.detect_logos_uri(file_name)
out, _ = capsys.readouterr()
assert 'Google' in out


def test_safe_search(cloud_config, capsys):
def test_safe_search(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/wakeupcat.jpg')
Expand All @@ -94,15 +92,14 @@ def test_safe_search(cloud_config, capsys):
assert 'Likelihood.VERY_LIKELY' in out


def test_safe_search_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/wakeupcat.jpg'.format(
cloud_config.storage_bucket))
def test_safe_search_uri(capsys):
file_name = 'gs://{}/vision/wakeupcat.jpg'.format(BUCKET)
detect.detect_safe_search_uri(file_name)
out, _ = capsys.readouterr()
assert 'Likelihood.VERY_LIKELY' in out


def test_detect_text(cloud_config, capsys):
def test_detect_text(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/text.jpg')
Expand All @@ -111,15 +108,14 @@ def test_detect_text(cloud_config, capsys):
assert '37%' in out


def test_detect_text_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/text.jpg'.format(
cloud_config.storage_bucket))
def test_detect_text_uri(capsys):
file_name = 'gs://{}/vision/text.jpg'.format(BUCKET)
detect.detect_text_uri(file_name)
out, _ = capsys.readouterr()
assert '37%' in out


def test_detect_properties(cloud_config, capsys):
def test_detect_properties(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/landmark.jpg')
Expand All @@ -128,16 +124,15 @@ def test_detect_properties(cloud_config, capsys):
assert 'frac' in out


def test_detect_properties_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/landmark.jpg'.format(
cloud_config.storage_bucket))
def test_detect_properties_uri(capsys):
file_name = 'gs://{}/vision/landmark.jpg'.format(BUCKET)
detect.detect_properties_uri(file_name)
out, _ = capsys.readouterr()
assert 'frac' in out


# Vision 1.1 tests
def test_detect_web(cloud_config, capsys):
def test_detect_web(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/landmark.jpg')
Expand All @@ -146,15 +141,14 @@ def test_detect_web(cloud_config, capsys):
assert 'Description: Palace of Fine Arts Theatre' in out


def test_detect_web_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/landmark.jpg'.format(
cloud_config.storage_bucket))
def test_detect_web_uri(capsys):
file_name = 'gs://{}/vision/landmark.jpg'.format(BUCKET)
detect.detect_web_uri(file_name)
out, _ = capsys.readouterr()
assert 'Description: Palace of Fine Arts Theatre' in out


def test_detect_document(cloud_config, capsys):
def test_detect_document(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/text.jpg')
Expand All @@ -163,15 +157,14 @@ def test_detect_document(cloud_config, capsys):
assert '37%' in out


def test_detect_document_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/text.jpg'.format(
cloud_config.storage_bucket))
def test_detect_document_uri(capsys):
file_name = 'gs://{}/vision/text.jpg'.format(BUCKET)
detect.detect_document_uri(file_name)
out, _ = capsys.readouterr()
assert '37%' in out


def test_detect_crop_hints(cloud_config, capsys):
def test_detect_crop_hints(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/wakeupcat.jpg')
Expand All @@ -180,9 +173,8 @@ def test_detect_crop_hints(cloud_config, capsys):
assert 'bounds: (0,0)' in out


def test_detect_crop_hints_uri(cloud_config, capsys):
file_name = ('gs://{}/vision/wakeupcat.jpg'.format(
cloud_config.storage_bucket))
def test_detect_crop_hints_uri(capsys):
file_name = 'gs://{}/vision/wakeupcat.jpg'.format(BUCKET)
detect.detect_crop_hints_uri(file_name)
out, _ = capsys.readouterr()
assert 'bounds: (0,0)' in out
2 changes: 1 addition & 1 deletion samples/snippets/document_text/doctext_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import doctext


def test_text(cloud_config, capsys):
def test_text(capsys):
"""Checks the output image for drawing the crop hint is created."""
doctext.render_doc_text('resources/text_menu.jpg', 'output-text.jpg')
out, _ = capsys.readouterr()
Expand Down
12 changes: 8 additions & 4 deletions samples/snippets/web/web_detect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import web_detect

BUCKET = os.environ['CLOUD_STORAGE_BUCKET']


def test_detect_file(cloud_config, capsys):
def test_detect_file(capsys):
file_name = ('../detect/resources/landmark.jpg')
web_detect.report(web_detect.annotate(file_name))
out, _ = capsys.readouterr()
assert 'Description: Palace of Fine Arts Theatre' in out


def test_detect_web_gsuri(cloud_config, capsys):
def test_detect_web_gsuri(capsys):
file_name = ('gs://{}/vision/landmark.jpg'.format(
cloud_config.storage_bucket))
BUCKET))
web_detect.report(web_detect.annotate(file_name))
out, _ = capsys.readouterr()
assert 'Description: Palace of Fine Arts Theatre' in out


def test_detect_web_http(cloud_config, capsys):
def test_detect_web_http(capsys):
web_detect.report(web_detect.annotate('https://goo.gl/X4qcB6'))
out, _ = capsys.readouterr()
assert 'https://cloud.google.com/vision/' in out

0 comments on commit a1897d4

Please sign in to comment.