88pytestmark = pytest .mark .django_db
99
1010
11- @pytest .fixture
12- def generate_base_component (component_base_factory , link_factory , group_factory ):
11+ def test_generate_base_component (group_factory , component_base_factory , link_factory ):
12+ group = group_factory (
13+ id = 1 , product_owner = "john" , project_owner = "doe"
14+ )
1315 component = component_base_factory (
1416 id = 1 ,
1517 name = "base" ,
18+ label = "Base" ,
1619 type = "database" ,
1720 description = "This is my fancy component" ,
1821 kind = "component" ,
1922 owner = "platform" ,
2023 service = None ,
2124 library = None ,
25+ group = group ,
2226 source__id = 1 ,
2327 source__remote_id = 1 ,
2428 source__owner = "jasckson" ,
2529 source__name = "thiwer" ,
2630 source__url = "https://gitlab.com/thiwer/thiwer" ,
2731 )
28- component .save ()
29-
30- group = group_factory (id = 1 , product_owner = "john" , project_owner = "doe" , entity = component )
31- group .save ()
3232
3333 link_factory (
3434 id = 1 ,
@@ -44,13 +44,12 @@ def generate_base_component(component_base_factory, link_factory, group_factory)
4444 entity = component ,
4545 )
4646
47-
48- def test_generate_base_component (generate_base_component ):
4947 expected = """
5048- apiVersion: v1alpha1
5149 kind_: component
5250 metadata:
5351 name: base
52+ label: Base
5453 owner: platform
5554 group:
5655 product_owner: john
@@ -64,11 +63,92 @@ def test_generate_base_component(generate_base_component):
6463 icon: poop
6564 - name: Sentry
6665 url: https://sentry.skypicker.com
67- icon: null
6866 spec:
6967 type_: database
7068"""
7169 repository = Repository .objects .get (pk = 1 )
7270 content = generate (repository )
7371 assert validate (content )
7472 assert expected .strip () == content .strip ()
73+
74+
75+ def test_generate_component_service (component_base_factory , service_factory , group_factory ,
76+ link_factory , repository_factory , environment_factory ):
77+ repository = repository_factory (
78+ id = 22 ,
79+ remote_id = 22 ,
80+ name = "test_proj1" ,
81+ owner = "john_doe1" ,
82+ url = "https://github.com/john_doe1/test_proj1" ,
83+ provider = "github" ,
84+ )
85+
86+ service = service_factory (
87+ owner = "platform" ,
88+ name = "my-service" ,
89+ lifecycle = "production" ,
90+ impact = "employees" ,
91+ repository = repository ,
92+ slack_channel = "#platform-software" ,
93+ docs_url = "https://docs.com"
94+ )
95+ environment_factory (
96+ name = "production" ,
97+ service = service ,
98+ health_check_url = "https://health.com" ,
99+ dashboard_url = "https://dashboard.datadog.com" ,
100+ service_urls = ["https://service.com" ]
101+ )
102+ group = group_factory (
103+ id = 1 , product_owner = "john" , project_owner = "doe"
104+ )
105+ component_service = component_base_factory (
106+ id = 1 ,
107+ name = "service" ,
108+ label = "Service" ,
109+ type = "service" ,
110+ description = "This is my fancy service" ,
111+ kind = "component" ,
112+ owner = "platform" ,
113+ service = service ,
114+ library = None ,
115+ group = group ,
116+ source = repository
117+ )
118+ link_factory (
119+ id = 1 ,
120+ name = "Datadog" ,
121+ url = "https://dashboard.datadog.com" ,
122+ icon = "poop" ,
123+ entity = component_service ,
124+ )
125+ expected = """
126+ - apiVersion: v1alpha1
127+ kind_: component
128+ metadata:
129+ name: service
130+ label: Service
131+ owner: platform
132+ group:
133+ product_owner: john
134+ project_owner: doe
135+ maintainers: []
136+ description: This is my fancy service
137+ tags: []
138+ links:
139+ - name: Datadog
140+ url: https://dashboard.datadog.com
141+ icon: poop
142+ spec:
143+ type_: service
144+ environments:
145+ - name: production
146+ dashboard_url: https://dashboard.datadog.com
147+ health_check_url: https://health.com
148+ service_urls:
149+ - https://service.com
150+ """
151+ repository = Repository .objects .get (pk = 22 )
152+ content = generate (repository )
153+ assert validate (content )
154+ assert expected .strip () == content .strip ()
0 commit comments