@@ -188,14 +188,115 @@ def test_deployment_view_add_deployment_node_adds_parent(empty_workspace: Worksp
188188 deployment_view = empty_workspace .views .create_deployment_view (
189189 software_system = software_system , key = "deployment" , description = "Description"
190190 )
191- deployment_view . add ( child_deployment_node )
191+ deployment_view += child_deployment_node
192192 element_views = deployment_view .element_views
193193 assert len (element_views ) == 3
194194 assert any ([x .element is parent_deployment_node for x in element_views ])
195195 assert any ([x .element is child_deployment_node for x in element_views ])
196196 assert any ([x .element is container_instance for x in element_views ])
197197
198198
199- # TODO: Animations
199+ def test_add_animation_step_raises_if_no_elements (empty_workspace : Workspace ):
200+ """Check error handling if no elements passed."""
201+ deployment_view = empty_workspace .views .create_deployment_view (
202+ key = "deployment" , description = "Description"
203+ )
204+ with pytest .raises (ValueError ):
205+ deployment_view .add_animation ()
206+
207+
208+ def test_add_animation_step (empty_workspace : Workspace ):
209+ """Check happy path."""
210+ model = empty_workspace .model
211+ views = empty_workspace .views
212+
213+ software_system = model .add_software_system ("Software System" )
214+ web_application = software_system .add_container ("Web Application" )
215+ database = software_system .add_container ("Database" )
216+ web_application .uses (database , "Reads from and writes to" , "JDBC/HTTPS" )
217+
218+ developer_laptop = model .add_deployment_node ("Developer Laptop" )
219+ apache_tomcat = developer_laptop .add_deployment_node ("Apache Tomcat" )
220+ oracle = developer_laptop .add_deployment_node ("Oracle" )
221+ web_application_instance = apache_tomcat .add_container (web_application )
222+ database_instance = oracle .add_container (database )
223+
224+ deployment_view = views .create_deployment_view (
225+ software_system = software_system , key = "deployment" , description = "Description"
226+ )
227+ deployment_view += developer_laptop
228+
229+ deployment_view .add_animation (web_application_instance )
230+ deployment_view .add_animation (database_instance )
231+
232+ step1 = deployment_view .animations [0 ]
233+ assert step1 .order == 1
234+ assert len (step1 .elements ) == 3
235+ assert developer_laptop .id in step1 .elements
236+ assert apache_tomcat .id in step1 .elements
237+ assert web_application_instance .id in step1 .elements
238+ assert len (step1 .relationships ) == 0
239+
240+ step2 = deployment_view .animations [1 ]
241+ assert step2 .order == 2
242+ assert len (step2 .elements ) == 2
243+ assert oracle .id in step2 .elements
244+ assert database_instance .id in step2 .elements
245+ assert len (step2 .relationships ) == 1
246+ assert next (iter (web_application_instance .relationships )).id in step2 .relationships
247+
248+
249+ def test_animation_ignores_containers_outside_this_view (empty_workspace : Workspace ):
250+ """Check that containers outside this view are ignored when adding animations."""
251+ model = empty_workspace .model
252+ views = empty_workspace .views
253+
254+ software_system = model .add_software_system ("Software System" )
255+ web_application = software_system .add_container ("Web Application" )
256+ database = software_system .add_container ("Database" )
257+ web_application .uses (database , "Reads from and writes to" , "JDBC/HTTPS" )
258+
259+ developer_laptop = model .add_deployment_node ("Developer Laptop" )
260+ apache_tomcat = developer_laptop .add_deployment_node ("Apache Tomcat" )
261+ oracle = developer_laptop .add_deployment_node ("Oracle" )
262+ web_application_instance = apache_tomcat .add_container (web_application )
263+ database_instance = oracle .add_container (database )
264+
265+ deployment_view = views .create_deployment_view (
266+ software_system = software_system , key = "deployment" , description = "Description"
267+ )
268+ deployment_view += apache_tomcat
269+
270+ # database_instance isn't in the view this time
271+ deployment_view .add_animation (web_application_instance , database_instance )
272+
273+ step1 = deployment_view .animations [0 ]
274+ assert developer_laptop .id in step1 .elements
275+ assert database .id not in step1 .elements
276+
277+
278+ def test_animation_raises_if_no_container_instances_found (empty_workspace : Workspace ):
279+ """Check error raised if no container instance exists in the view."""
280+ model = empty_workspace .model
281+ views = empty_workspace .views
282+
283+ software_system = model .add_software_system ("Software System" )
284+ web_application = software_system .add_container ("Web Application" )
285+ database = software_system .add_container ("Database" )
286+ web_application .uses (database , "Reads from and writes to" , "JDBC/HTTPS" )
287+
288+ developer_laptop = model .add_deployment_node ("Developer Laptop" )
289+ apache_tomcat = developer_laptop .add_deployment_node ("Apache Tomcat" )
290+ oracle = developer_laptop .add_deployment_node ("Oracle" )
291+ web_application_instance = apache_tomcat .add_container (web_application )
292+ database_instance = oracle .add_container (database )
293+
294+ deployment_view = views .create_deployment_view (
295+ software_system = software_system , key = "deployment" , description = "Description"
296+ )
297+
298+ with pytest .raises (ValueError ):
299+ deployment_view .add_animation (web_application_instance , database_instance )
300+
200301
201302# TODO: Removing
0 commit comments