@@ -462,6 +462,80 @@ def construct_required_body(self):
462
462
return body
463
463
464
464
465
+ #-----------------------------------------------------------------------------
466
+ # Test Class for get_model_file
467
+ #-----------------------------------------------------------------------------
468
+ class TestGetModelFile ():
469
+
470
+ #--------------------------------------------------------
471
+ # Test 1: Send fake data and check response
472
+ #--------------------------------------------------------
473
+ @responses .activate
474
+ def test_get_model_file_response (self ):
475
+ body = self .construct_full_body ()
476
+ response = fake_response_BinaryIO_json
477
+ send_request (self , body , response )
478
+ assert len (responses .calls ) == 1
479
+
480
+ #--------------------------------------------------------
481
+ # Test 2: Send only required fake data and check response
482
+ #--------------------------------------------------------
483
+ @responses .activate
484
+ def test_get_model_file_required_response (self ):
485
+ # Check response with required params
486
+ body = self .construct_required_body ()
487
+ response = fake_response_BinaryIO_json
488
+ send_request (self , body , response )
489
+ assert len (responses .calls ) == 1
490
+
491
+ #--------------------------------------------------------
492
+ # Test 3: Send empty data and check response
493
+ #--------------------------------------------------------
494
+ @responses .activate
495
+ def test_get_model_file_empty (self ):
496
+ check_empty_required_params (self , fake_response_BinaryIO_json )
497
+ check_missing_required_params (self )
498
+ assert len (responses .calls ) == 0
499
+
500
+ #-----------
501
+ #- Helpers -
502
+ #-----------
503
+ def make_url (self , body ):
504
+ endpoint = '/v4/collections/{0}/model' .format (body ['collection_id' ])
505
+ url = '{0}{1}' .format (base_url , endpoint )
506
+ return url
507
+
508
+ def add_mock_response (self , url , response ):
509
+ responses .add (responses .GET ,
510
+ url ,
511
+ body = json .dumps (response ),
512
+ status = 200 ,
513
+ content_type = '' )
514
+
515
+ def call_service (self , body ):
516
+ service = VisualRecognitionV4 (
517
+ authenticator = NoAuthAuthenticator (),
518
+ version = '2019-02-11' ,
519
+ )
520
+ service .set_service_url (base_url )
521
+ output = service .get_model_file (** body )
522
+ return output
523
+
524
+ def construct_full_body (self ):
525
+ body = dict ()
526
+ body ['collection_id' ] = "string1"
527
+ body ['feature' ] = "string1"
528
+ body ['model_format' ] = "string1"
529
+ return body
530
+
531
+ def construct_required_body (self ):
532
+ body = dict ()
533
+ body ['collection_id' ] = "string1"
534
+ body ['feature' ] = "string1"
535
+ body ['model_format' ] = "string1"
536
+ return body
537
+
538
+
465
539
# endregion
466
540
##############################################################################
467
541
# End of Service: Collections
@@ -1504,17 +1578,18 @@ def send_request(obj, body, response, url=None):
1504
1578
1505
1579
fake_response__json = None
1506
1580
fake_response_AnalyzeResponse_json = """{"images": [], "warnings": [], "trace": "fake_trace"}"""
1507
- fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "description": "fake_description"}}}"""
1581
+ fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "rscnn_ready": false, " description": "fake_description"}}}"""
1508
1582
fake_response_CollectionsList_json = """{"collections": []}"""
1509
- fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "description": "fake_description"}}}"""
1510
- fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "description": "fake_description"}}}"""
1583
+ fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "rscnn_ready": false, "description": "fake_description"}}}"""
1584
+ fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "rscnn_ready": false, "description": "fake_description"}}}"""
1585
+ fake_response_BinaryIO_json = """Contents of response byte-stream..."""
1511
1586
fake_response_ImageDetailsList_json = """{"images": [], "warnings": [], "trace": "fake_trace"}"""
1512
1587
fake_response_ImageSummaryList_json = """{"images": []}"""
1513
1588
fake_response_ImageDetails_json = """{"image_id": "fake_image_id", "updated": "2017-05-16T13:56:54.957Z", "created": "2017-05-16T13:56:54.957Z", "source": {"type": "fake_type", "filename": "fake_filename", "archive_filename": "fake_archive_filename", "source_url": "fake_source_url", "resolved_url": "fake_resolved_url"}, "dimensions": {"height": 6, "width": 5}, "errors": [], "training_data": {"objects": []}}"""
1514
1589
fake_response_BinaryIO_json = """Contents of response byte-stream..."""
1515
1590
fake_response_ObjectMetadataList_json = """{"object_count": 12, "objects": []}"""
1516
1591
fake_response_UpdateObjectMetadata_json = """{"object": "fake_object", "count": 5}"""
1517
1592
fake_response_ObjectMetadata_json = """{"object": "fake_object", "count": 5}"""
1518
- fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "description": "fake_description"}}}"""
1593
+ fake_response_Collection_json = """{"collection_id": "fake_collection_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "image_count": 11, "training_status": {"objects": {"ready": false, "in_progress": false, "data_changed": true, "latest_failed": false, "rscnn_ready": false, " description": "fake_description"}}}"""
1519
1594
fake_response_TrainingDataObjects_json = """{"objects": []}"""
1520
1595
fake_response_TrainingEvents_json = """{"start_time": "2017-05-16T13:56:54.957Z", "end_time": "2017-05-16T13:56:54.957Z", "completed_events": 16, "trained_images": 14, "events": []}"""
0 commit comments