1
1
import unittest
2
+ import yaml
2
3
from http import HTTPStatus
4
+ from typing import Optional , List , Union
3
5
4
6
from abstract_test_case import AbstractTestCase
5
7
from cloudfoundry_client .common_objects import JsonObject
@@ -132,3 +134,30 @@ def test_list_include_space(self):
132
134
self .assertIsInstance (all_spaces [0 ], Entity )
133
135
self .assertEqual (all_spaces [1 ]["name" ], "my_space" )
134
136
self .assertIsInstance (all_spaces [1 ], Entity )
137
+
138
+ def test_get_manifest (self ):
139
+ self .client .get .return_value = self .mock_response (
140
+ "/v3/apps/app_id/manifest" , HTTPStatus .OK , {"Content-Type" : "application/x-yaml" }, "v3" , "apps" ,
141
+ "GET_{id}_manifest_response.yml"
142
+ )
143
+ manifest_response : str = self .client .v3 .apps .get_manifest ("app_id" )
144
+ self .assertIsInstance (manifest_response , str )
145
+ manifest : dict = yaml .safe_load (manifest_response )
146
+ applications : Optional [list [dict ]] = manifest .get ("applications" )
147
+ self .assertIsInstance (applications , list )
148
+ self .assertEqual (len (applications ), 1 )
149
+ application : dict = applications [0 ]
150
+ self .assertEqual (application .get ("name" ), "my-app" )
151
+ self .assertEqual (application .get ("stack" ), "cflinuxfs4" )
152
+ self .assertEqual (len (application .get ("services" , [])), 1 )
153
+ application_services : Optional [list [str ]] = application .get ("services" )
154
+ self .assertIsInstance (application_services , list )
155
+ self .assertEqual (len (application_services ),1 )
156
+ self .assertEqual (application_services [0 ],"my-service" )
157
+ application_routes : Optional [List [Union [dict ,str ]]] = application .get ("routes" )
158
+ self .assertIsInstance (application_routes ,list )
159
+ self .assertEqual (len (application_routes ),1 )
160
+ application_route : dict = application_routes [0 ]
161
+ self .assertIsInstance (application_route ,dict )
162
+ self .assertEqual (application_route .get ("route" ),"my-app.example.com" )
163
+ self .assertEqual (application_route .get ("protocol" ),"http1" )
0 commit comments