Skip to content

Commit b9b4bfe

Browse files
committed
Test that metadata is updated with update function
1 parent 0edb30e commit b9b4bfe

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

dev-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
PyYAML==5.2
44
Pygments==2.5.2
55
Sphinx-Substitution-Extensions==2019.6.15.0
6-
Sphinx==2.2.2
6+
Sphinx==2.3.0
77
VWS-Python-Mock==2019.12.7.1
8-
VWS-Test-Fixtures==2019.12.13.0
8+
VWS-Test-Fixtures==2019.12.13.1
99
autoflake==1.3.1
1010
check-manifest==0.40
1111
codecov==2.0.15 # Upload coverage data

tests/test_vws.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import base64
66
import io
7+
import random
8+
import uuid
79
from typing import Optional
810

911
import pytest
@@ -472,37 +474,58 @@ def test_update_target(
472474
self,
473475
vws_client: VWS,
474476
high_quality_image: io.BytesIO,
475-
image_file_failed_state: io.BytesIO,
477+
different_high_quality_image: io.BytesIO,
478+
cloud_reco_client: CloudRecoService,
476479
) -> None:
477480
"""
478481
It is possible to update a target.
479482
"""
483+
old_name = uuid.uuid4().hex
484+
old_width = random.uniform(a=0.01, b=50)
480485
target_id = vws_client.add_target(
481-
name='x',
482-
width=1,
486+
name=old_name,
487+
width=old_width,
483488
image=high_quality_image,
484489
active_flag=True,
485490
application_metadata=None,
486491
)
487492
vws_client.wait_for_target_processed(target_id=target_id)
488493
report = vws_client.get_target_summary_report(target_id=target_id)
489-
assert report['status'] == 'success'
494+
[matching_target] = cloud_reco_client.query(image=high_quality_image)
495+
assert matching_target['target_id'] == target_id
496+
query_target_data = matching_target['target_data']
497+
query_metadata = query_target_data['application_metadata']
498+
assert query_metadata is None
499+
500+
new_name = uuid.uuid4().hex
501+
new_width = random.uniform(a=0.01, b=50)
502+
new_application_metadata = base64.b64encode(b'a').decode('ascii')
490503
vws_client.update_target(
491504
target_id=target_id,
492-
name='x2',
493-
width=2,
494-
active_flag=False,
495-
image=image_file_failed_state,
496-
application_metadata=base64.b64encode(b'a').decode('ascii'),
505+
name=new_name,
506+
width=new_width,
507+
active_flag=True,
508+
image=different_high_quality_image,
509+
application_metadata=new_application_metadata,
497510
)
498511

499512
vws_client.wait_for_target_processed(target_id=target_id)
513+
[matching_target
514+
] = cloud_reco_client.query(image=different_high_quality_image, )
515+
assert matching_target['target_id'] == target_id
516+
query_target_data = matching_target['target_data']
517+
query_metadata = query_target_data['application_metadata']
518+
assert query_metadata == new_application_metadata
519+
520+
vws_client.update_target(
521+
target_id=target_id,
522+
active_flag=False,
523+
)
524+
500525
target_details = vws_client.get_target_record(target_id=target_id)
501-
assert target_details['name'] == 'x2'
502-
assert target_details['width'] == 2
526+
assert target_details['name'] == new_name
527+
assert target_details['width'] == new_width
503528
assert not target_details['active_flag']
504-
report = vws_client.get_target_summary_report(target_id=target_id)
505-
assert report['status'] == 'failed'
506529

507530
def test_no_fields_given(
508531
self,

0 commit comments

Comments
 (0)