22
33import pytest
44
5+ from slp_visio .slp_visio .load .objects .diagram_objects import DiagramComponent
6+
57from slp_base import MappingFileNotValidError
68from slp_visio .slp_visio .parse .mappers .diagram_component_mapper import DiagramComponentMapper
79
8- tz1 = MagicMock (id = 'tz1' )
9- c1 = MagicMock (id = 'c1' )
10+ tz1 = DiagramComponent (id = 'tz1' )
11+ c1 = DiagramComponent (id = 'c1' , name = 'Component 1 ' )
1012c1 .parent = tz1
11- c2 = MagicMock (id = 'c2' )
13+ c2 = DiagramComponent (id = 'c2' , name = 'Component 2 ' )
1214c2 .parent = c1
13- c3 = MagicMock (id = 'c3' )
15+ c3 = DiagramComponent (id = 'c3' , name = '3 ' )
1416c3 .parent = None
15- c4 = MagicMock (id = 'c4' )
17+ c4 = DiagramComponent (id = 'c4' , name = 'Component 4 ' )
1618
1719
1820diagram_components = [tz1 , c1 , c2 , c3 , c4 ]
@@ -53,17 +55,20 @@ def test_to_otm(self):
5355 assert components [0 ].id == 'c1'
5456 assert components [0 ].type == 'type-1'
5557 assert components [0 ].parent == 'tz1'
58+ assert components [0 ].name == c1 .name
5659
5760 assert components [1 ].id == 'c2'
5861 assert components [1 ].type == 'type-2'
5962 assert components [1 ].parent == 'c1'
63+ assert components [1 ].name == c2 .name
6064
6165 assert components [2 ].id == 'c3'
6266 assert components [2 ].type == 'type-3'
6367 assert components [2 ].parent == default_trustzone .id
68+ assert components [2 ].name == f"_{ c3 .name } "
6469
6570 def test_not_default_trustzone (self ):
66- # GIVEN the diagram component mapper without default trustzone
71+ # GIVEN the diagram component mapper without a default trustzone
6772 diagram_component_mapper = DiagramComponentMapper (
6873 diagram_components ,
6974 component_mappings ,
@@ -72,15 +77,11 @@ def test_not_default_trustzone(self):
7277 representation_calculator
7378 )
7479
75- # WHEN to_otm is called an exception is raised
80+ # WHEN to_otm is called, expect an exception
7681 with pytest .raises (MappingFileNotValidError ) as error :
7782 diagram_component_mapper .to_otm ()
7883
79- # THEN the exception is raised
84+ # THEN an exception is raised
8085 assert error .value .title == 'Mapping files are not valid'
8186 assert error .value .detail == 'No default trust zone has been defined in the mapping file'
82- assert error .value .message == 'Please, add a default trust zone'
83-
84-
85-
86-
87+ assert error .value .message == 'Please, add a default trust zone'
0 commit comments