Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vision semi-GAPIC #3373

Merged
merged 34 commits into from
Jun 2, 2017
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a558ef1
[WIP] Vision semi-GAPIC
lukesneeringer May 3, 2017
bbc0bc8
[WIP] Vision semi-GAPIC, with future proof single feature methods.
May 3, 2017
6f627e4
WIP
May 3, 2017
2f69e39
WIP
lukesneeringer May 3, 2017
16daf25
WIP
May 3, 2017
7d975cb
[WIP] More Vision work.
May 4, 2017
04811d0
Working Vision client.
May 4, 2017
92cea0f
Re-adding old system tests; about to port.
May 4, 2017
f926516
Adding basic system tests.
May 4, 2017
cab525d
Rewrote usage docs for Vision
May 4, 2017
29ae515
Re-add old manual layer.
May 9, 2017
7249a15
Deprecate the old manual layer.
May 9, 2017
026a3c2
Remove requirements.txt
May 9, 2017
047d8d5
Re-add fail-under: 100 in .coveragerc
May 9, 2017
d01b94a
Fix credentials in unit test.
May 10, 2017
05063c3
Only run system tests where credentials are set.
May 10, 2017
6e0f282
File object support.
lukesneeringer May 15, 2017
18dce1c
Vision unit tests for file handling.
May 16, 2017
27593d7
Merge branch 'master' into vision-semi-gapic
lukesneeringer May 23, 2017
42c2b2e
Fix Vision MANIFEST.in
May 23, 2017
d4cdde4
Update versions in metapackage.
May 23, 2017
5566806
Modify a docstring. See if it makes sphinx not warn.
May 23, 2017
4604703
Let Sphinx warn.
May 23, 2017
11e02c3
Merge branch 'public-master' into vision-semi-gapic
Jun 1, 2017
4cf25eb
Wrangle Vision docs.
Jun 1, 2017
d97ed34
Improve proto docs (e.g. there are some now).
Jun 1, 2017
276df35
Greatly improve docs
Jun 1, 2017
8d4b5c5
Remove a trailing colon from see, fixes 63 warnings.
Jun 1, 2017
085fca8
Remove a trailing colon from see, fixes 63 warnings.
Jun 1, 2017
b89d3e6
Wipe out all trailing colons after the word See
Jun 1, 2017
6fdb2f4
Vision docs (and no warnings).
Jun 2, 2017
2148eb0
Improve docs.
Jun 2, 2017
0dc3ac5
Move GAPIC docs into their own directory.
Jun 2, 2017
36c8927
Add intersphinx for gax/grpc
Jun 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Vision unit tests for file handling.
  • Loading branch information
Luke Sneeringer committed May 16, 2017
commit 18dce1c418925cbc827d8fe9403b38422d5a3a0a
40 changes: 40 additions & 0 deletions vision/tests/unit/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,43 @@ def test_image_file_handler(self, batch_annotate):
file_ = io.BytesIO(b'bogus==')

# Perform the single image request.
self.client.annotate_image({'image': file_})

# Evaluate the argument sent to batch_annotate_images.
assert batch_annotate.call_count == 1
_, args, kwargs = batch_annotate.mock_calls[0]

# Only a single request object should be sent.
assert len(args[0]) == 1

# Evalute the request object to ensure it looks correct.
request_sent = args[0][0]
assert request_sent['image']['content'] == b'bogus=='

@mock.patch.object(ImageAnnotatorClient, 'batch_annotate_images')
@mock.patch.object(io, 'open')
def test_image_filename(self, io_open, batch_annotate):
# Make io.open send back a mock with a read method.
file_ = mock.MagicMock(spec=io.BytesIO)
io_open.return_value = file_
file_.__enter__.return_value = file_
file_.read.return_value = b'imagefile=='

# Perform the single image request using a filename.
self.client.annotate_image(
{'image': {'source': {'filename': 'image.jpeg'}}},
)

# Establish that my file was opened.
io_open.assert_called_once_with('image.jpeg', 'rb')

# Evalute the argument sent to batch_annotate_images.
assert batch_annotate.call_count == 1
_, args, kwargs = batch_annotate.mock_calls[0]

# Only a single request object should be sent.
assert len(args[0]) == 1

# Evalute the request object to ensure it looks correct.
request_sent = args[0][0]
assert request_sent['image']['content'] == b'imagefile=='