Skip to content

Commit aef60de

Browse files
committed
test: Add test for the v3 apps get_manifest function
1 parent 6f289ee commit aef60de

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
applications:
3+
- name: my-app
4+
stack: cflinuxfs4
5+
features:
6+
ssh: true
7+
revisions: true
8+
service-binding-k8s: false
9+
file-based-vcap-services: false
10+
services:
11+
- my-service
12+
routes:
13+
- route: my-app.example.com
14+
protocol: http1
15+
processes:
16+
- type: web
17+
instances: 2
18+
memory: 512M
19+
log-rate-limit-per-second: 1KB
20+
disk_quota: 1024M
21+
health-check-type: http
22+
health-check-http-endpoint: /healthy
23+
health-check-invocation-timeout: 10
24+
health-check-interval: 5
25+
readiness-health-check-type: http
26+
readiness-health-check-http-endpoint: /ready
27+
readiness-health-check-invocation-timeout: 20
28+
readiness-health-check-interval: 5

tests/v3/test_apps.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
2+
import yaml
23
from http import HTTPStatus
4+
from typing import Optional, List, Union
35

46
from abstract_test_case import AbstractTestCase
57
from cloudfoundry_client.common_objects import JsonObject
@@ -132,3 +134,30 @@ def test_list_include_space(self):
132134
self.assertIsInstance(all_spaces[0], Entity)
133135
self.assertEqual(all_spaces[1]["name"], "my_space")
134136
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

Comments
 (0)