151151 ),
152152)
153153
154+ BaseTestCase .registerHttpGetHandler (
155+ url = "https://127.0.0.1:8080/api/v1/catalog/102" ,
156+ response = MockResponse (
157+ json_data = {"garbage" }, status_code = 200 , headers = dict (),
158+ ),
159+ )
160+
154161BaseTestCase .registerHttpGetHandler (
155162 url = "https://127.0.0.1:8080/api/v1/catalog" ,
156163 response = MockResponse (
@@ -591,66 +598,8 @@ def test_list_with_query_and_text_output(self, mock_post, mock_get):
591598
592599
593600class TestCLIGet (BaseTestCase ):
594- def mocked_requests_get (* args , ** kwargs ):
595- if args [0 ] == "https://127.0.0.1:8080/api/v1/catalog/100" :
596- return MockResponse (
597- json_data = {
598- "_links" : {
599- "self" : {"href" : "/api/v1/catalog/100" },
600- "feed" : [
601- {
602- "href" : (
603- "https://s3.amazonaws.com/bluedata-catalog/"
604- "bundles/catalog/external/docker/EPIC-5.0/"
605- "feeds/feed.json"
606- ),
607- "name" : (
608- "BlueData EPIC-5.0 catalog feed for docker"
609- ),
610- }
611- ],
612- },
613- "id" : "/api/v1/catalog/100" ,
614- "distro_id" : "bluedata/spark240juphub7xssl" ,
615- "label" : {
616- "name" : "Spark240" ,
617- "description" : ("The description" ),
618- },
619- "version" : "2.8" ,
620- "timestamp" : 0 ,
621- "isdebug" : False ,
622- "osclass" : ["centos" ],
623- "logo" : {
624- "checksum" : "1471eb59356066ed4a06130566764ea6" ,
625- "url" : (
626- "http://10.1.0.53/catalog/logos/"
627- "bluedata-spark240juphub7xssl-2.8"
628- ),
629- },
630- "documentation" : {
631- "checksum" : "52f53f1b2845463b9e370d17fb80bea6" ,
632- "mimetype" : "text/markdown" ,
633- "file" : (
634- "/opt/bluedata/catalog/documentation/"
635- "bluedata-spark240juphub7xssl-2.8"
636- ),
637- },
638- "state" : "initialized" ,
639- "state_info" : "" ,
640- },
641- status_code = 200 ,
642- headers = dict (),
643- )
644- if args [0 ] == "https://127.0.0.1:8080/api/v1/catalog/101" :
645- raise APIItemNotFoundException (
646- message = "catalog not found with id: " + "/api/v1/catalog/101" ,
647- request_method = "get" ,
648- request_url = args [0 ],
649- )
650- raise RuntimeError ("Unhandle GET request: " + args [0 ])
651-
652601 @patch ("requests.post" , side_effect = BaseTestCase .httpPostHandlers )
653- @patch ("requests.get" , side_effect = mocked_requests_get )
602+ @patch ("requests.get" , side_effect = BaseTestCase . httpGetHandlers )
654603 def test_get_output_is_valid_yaml (self , mock_post , mock_get ):
655604
656605 self .maxDiff = None
@@ -665,7 +614,7 @@ def test_get_output_is_valid_yaml(self, mock_post, mock_get):
665614 self .fail ("Output should be valid yaml" )
666615
667616 @patch ("requests.post" , side_effect = BaseTestCase .httpPostHandlers )
668- @patch ("requests.get" , side_effect = mocked_requests_get )
617+ @patch ("requests.get" , side_effect = BaseTestCase . httpGetHandlers )
669618 def test_get_yaml_output_is_valid (self , mock_post , mock_get ):
670619
671620 self .maxDiff = None
@@ -695,7 +644,7 @@ def test_get_yaml_output_is_valid(self, mock_post, mock_get):
695644id: /api/v1/catalog/100
696645isdebug: false
697646label:
698- description: The description
647+ description: Spark240 multirole with Jupyter Notebook, Jupyterhub with SSL and gateway node
699648 name: Spark240
700649logo:
701650 checksum: 1471eb59356066ed4a06130566764ea6
@@ -715,7 +664,7 @@ def test_get_yaml_output_is_valid(self, mock_post, mock_get):
715664 )
716665
717666 @patch ("requests.post" , side_effect = BaseTestCase .httpPostHandlers )
718- @patch ("requests.get" , side_effect = mocked_requests_get )
667+ @patch ("requests.get" , side_effect = BaseTestCase . httpGetHandlers )
719668 def test_get_json_output (self , mock_post , mock_get ):
720669
721670 self .maxDiff = None
@@ -746,7 +695,10 @@ def test_get_json_output(self, mock_post, mock_get):
746695 "distro_id" : "bluedata/spark240juphub7xssl" ,
747696 "label" : {
748697 "name" : "Spark240" ,
749- "description" : "The description" ,
698+ "description" : (
699+ "Spark240 multirole with Jupyter Notebook, Jupyterhub"
700+ " with SSL and gateway node"
701+ ),
750702 },
751703 "state" : "initialized" ,
752704 "version" : "2.8" ,
@@ -763,7 +715,7 @@ def test_get_json_output(self, mock_post, mock_get):
763715 )
764716
765717 @patch ("requests.post" , side_effect = BaseTestCase .httpPostHandlers )
766- @patch ("requests.get" , side_effect = mocked_requests_get )
718+ @patch ("requests.get" , side_effect = BaseTestCase . httpGetHandlers )
767719 def test_get_output_with_invalid_catalog_id (self , mock_post , mock_get ):
768720
769721 with self .assertRaises (SystemExit ) as cm :
@@ -794,12 +746,12 @@ def mocked_requests_garbage_data(*args, **kwargs):
794746 raise RuntimeError ("Unhandle GET request: " + args [0 ])
795747
796748 @patch ("requests.post" , side_effect = BaseTestCase .httpPostHandlers )
797- @patch ("requests.get" , side_effect = mocked_requests_garbage_data )
749+ @patch ("requests.get" , side_effect = BaseTestCase . httpGetHandlers )
798750 def test_get_output_with_unknown_exception (self , mock_post , mock_get ):
799751
800752 with self .assertRaises (SystemExit ) as cm :
801753 hpecp = self .cli .CLI ()
802- hpecp .catalog .get ("/api/v1/catalog/101 " )
754+ hpecp .catalog .get ("/api/v1/catalog/102 " )
803755
804756 self .assertEqual (cm .exception .code , 1 )
805757
0 commit comments