|
4 | 4 |
|
5 | 5 | import base64 |
6 | 6 | import io |
| 7 | +import random |
| 8 | +import uuid |
7 | 9 | from typing import Optional |
8 | 10 |
|
9 | 11 | import pytest |
@@ -472,37 +474,58 @@ def test_update_target( |
472 | 474 | self, |
473 | 475 | vws_client: VWS, |
474 | 476 | high_quality_image: io.BytesIO, |
475 | | - image_file_failed_state: io.BytesIO, |
| 477 | + different_high_quality_image: io.BytesIO, |
| 478 | + cloud_reco_client: CloudRecoService, |
476 | 479 | ) -> None: |
477 | 480 | """ |
478 | 481 | It is possible to update a target. |
479 | 482 | """ |
| 483 | + old_name = uuid.uuid4().hex |
| 484 | + old_width = random.uniform(a=0.01, b=50) |
480 | 485 | target_id = vws_client.add_target( |
481 | | - name='x', |
482 | | - width=1, |
| 486 | + name=old_name, |
| 487 | + width=old_width, |
483 | 488 | image=high_quality_image, |
484 | 489 | active_flag=True, |
485 | 490 | application_metadata=None, |
486 | 491 | ) |
487 | 492 | vws_client.wait_for_target_processed(target_id=target_id) |
488 | | - report = vws_client.get_target_summary_report(target_id=target_id) |
489 | | - assert report['status'] == 'success' |
| 493 | + [matching_target] = cloud_reco_client.query(image=high_quality_image) |
| 494 | + assert matching_target['target_id'] == target_id |
| 495 | + query_target_data = matching_target['target_data'] |
| 496 | + query_metadata = query_target_data['application_metadata'] |
| 497 | + assert query_metadata is None |
| 498 | + |
| 499 | + new_name = uuid.uuid4().hex |
| 500 | + new_width = random.uniform(a=0.01, b=50) |
| 501 | + new_application_metadata = base64.b64encode(b'a').decode('ascii') |
490 | 502 | vws_client.update_target( |
491 | 503 | 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'), |
| 504 | + name=new_name, |
| 505 | + width=new_width, |
| 506 | + active_flag=True, |
| 507 | + image=different_high_quality_image, |
| 508 | + application_metadata=new_application_metadata, |
497 | 509 | ) |
498 | 510 |
|
499 | 511 | vws_client.wait_for_target_processed(target_id=target_id) |
| 512 | + [ |
| 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 | + |
500 | 525 | 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 |
503 | 528 | assert not target_details['active_flag'] |
504 | | - report = vws_client.get_target_summary_report(target_id=target_id) |
505 | | - assert report['status'] == 'failed' |
506 | 529 |
|
507 | 530 | def test_no_fields_given( |
508 | 531 | self, |
|
0 commit comments