py-eb-model 1.1.6__py3-none-any.whl → 1.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eb_model/cli/rte_xdm_2_xls_cli.py +28 -27
- eb_model/models/abstract.py +20 -8
- eb_model/models/os_xdm.py +320 -55
- eb_model/models/rte_xdm.py +16 -11
- eb_model/parser/eb_parser.py +28 -20
- eb_model/parser/os_xdm_parser.py +47 -3
- eb_model/parser/rte_xdm_parser.py +11 -11
- eb_model/reporter/excel_reporter/abstract.py +14 -6
- eb_model/reporter/excel_reporter/os_xdm.py +104 -20
- eb_model/reporter/excel_reporter/rte_xdm.py +15 -4
- eb_model/tests/models/test_abstract.py +201 -0
- eb_model/tests/models/test_eb_doc.py +66 -0
- eb_model/tests/models/test_eclipse_project.py +21 -0
- eb_model/tests/models/test_importer_xdm.py +45 -40
- eb_model/tests/parser/__init__.py +0 -0
- eb_model/tests/parser/test_os_xdm_parser.py +150 -0
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/METADATA +7 -1
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/RECORD +22 -17
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/LICENSE +0 -0
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/WHEEL +0 -0
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/entry_points.txt +0 -0
- {py_eb_model-1.1.6.dist-info → py_eb_model-1.1.7.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
|
-
from ...models.rte_xdm import RteBswEventToTaskMapping,
|
1
|
+
from ...models.rte_xdm import RteBswEventToTaskMapping, RteBswEventToTaskMappingV3, RteBswEventToTaskMappingV4, RteBswModuleInstance
|
2
|
+
from ...models.rte_xdm import RteEventToTaskMapping, RteEventToTaskMappingV3, RteEventToTaskMappingV4, RteSwComponentInstance
|
2
3
|
from ...models.eb_doc import EBModel
|
3
4
|
from .abstract import ExcelReporter
|
4
5
|
|
@@ -59,19 +60,29 @@ class RteRunnableEntityXlsWriter(ExcelReporter):
|
|
59
60
|
|
60
61
|
row = 2
|
61
62
|
for os_task, mappings in doc.getRte().getMappedEvents().items():
|
62
|
-
for mapping in sorted(mappings, key=lambda a: a.
|
63
|
+
for mapping in sorted(mappings, key=lambda a: a.getRtePositionInTaskNumber()):
|
63
64
|
self.write_cell(sheet, row, 1, os_task)
|
64
65
|
if isinstance(mapping, RteBswEventToTaskMapping):
|
65
66
|
self.logger.debug("Write Mapping %s" % mapping.getName())
|
66
67
|
instance = mapping.getRteBswModuleInstance()
|
67
|
-
|
68
|
+
if isinstance(mapping, RteBswEventToTaskMappingV3):
|
69
|
+
self.write_cell(sheet, row, 2, mapping.getRteBswEventRef().getShortName())
|
70
|
+
elif isinstance(mapping, RteBswEventToTaskMappingV4):
|
71
|
+
self.write_cell(sheet, row, 2, " ".join(map(lambda i: i.getShortName(), mapping.getRteBswEventRefs())))
|
72
|
+
else:
|
73
|
+
raise NotImplementedError("Unsupported RteEventToTaskMapping")
|
68
74
|
self.write_cell(sheet, row, 5, instance.getRteBswImplementationRef().getValue())
|
69
75
|
self.write_cell(sheet, row, 6, mapping.getRteBswPositionInTask())
|
70
76
|
self.write_cell(sheet, row, 7, mapping.getRteBswActivationOffset())
|
71
77
|
elif isinstance(mapping, RteEventToTaskMapping):
|
72
78
|
self.logger.debug("Write Mapping %s" % mapping.getName())
|
73
79
|
instance = mapping.getRteSwComponentInstance()
|
74
|
-
|
80
|
+
if isinstance(mapping, RteEventToTaskMappingV3):
|
81
|
+
self.write_cell(sheet, row, 2, mapping.getRteEventRef().getShortName())
|
82
|
+
elif instance(mapping, RteEventToTaskMappingV4):
|
83
|
+
self.write_cell(sheet, row, 2, " ".join(map(lambda i: i.getShortName(), mapping.getRteEventRefs())))
|
84
|
+
else:
|
85
|
+
raise NotImplementedError("Unsupported RteEventToTaskMapping")
|
75
86
|
self.write_cell(sheet, row, 5, instance.getRteSoftwareComponentInstanceRef().getValue())
|
76
87
|
self.write_cell(sheet, row, 6, mapping.getRtePositionInTask())
|
77
88
|
self.write_cell(sheet, row, 7, mapping.getRteActivationOffset())
|
@@ -0,0 +1,201 @@
|
|
1
|
+
import pytest
|
2
|
+
from ...models.abstract import Module, EcucParamConfContainerDef, Version, EcucRefType, EcucObject, EcucEnumerationParamDef
|
3
|
+
from ...models.eb_doc import EBModel
|
4
|
+
|
5
|
+
|
6
|
+
class TestModule:
|
7
|
+
|
8
|
+
def test_module_initialization(self):
|
9
|
+
root = EBModel.getInstance()
|
10
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
11
|
+
module = Module(parent, "TestModule")
|
12
|
+
|
13
|
+
assert module.getName() == "TestModule"
|
14
|
+
assert module.getParent() == parent
|
15
|
+
assert isinstance(module.getArVersion(), Version)
|
16
|
+
assert isinstance(module.getSwVersion(), Version)
|
17
|
+
|
18
|
+
def test_module_ar_version(self):
|
19
|
+
root = EBModel.getInstance()
|
20
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
21
|
+
module = Module(parent, "TestModule")
|
22
|
+
|
23
|
+
ar_version = module.getArVersion()
|
24
|
+
ar_version.setMajorVersion(1).setMinorVersion(2).setPatchVersion(3)
|
25
|
+
|
26
|
+
assert ar_version.getMajorVersion() == 1
|
27
|
+
assert ar_version.getMinorVersion() == 2
|
28
|
+
assert ar_version.getPatchVersion() == 3
|
29
|
+
|
30
|
+
# Check the version string format
|
31
|
+
assert ar_version.getVersion() == "1.2.3"
|
32
|
+
|
33
|
+
def test_module_sw_version(self):
|
34
|
+
root = EBModel.getInstance()
|
35
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
36
|
+
module = Module(parent, "TestModule")
|
37
|
+
|
38
|
+
sw_version = module.getSwVersion()
|
39
|
+
sw_version.setMajorVersion(4).setMinorVersion(5).setPatchVersion(6)
|
40
|
+
|
41
|
+
assert sw_version.getMajorVersion() == 4
|
42
|
+
assert sw_version.getMinorVersion() == 5
|
43
|
+
assert sw_version.getPatchVersion() == 6
|
44
|
+
|
45
|
+
# Check the version string format
|
46
|
+
assert sw_version.getVersion() == "4.5.6"
|
47
|
+
|
48
|
+
def test_module_add_and_get_element(self):
|
49
|
+
root = EBModel.getInstance()
|
50
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
51
|
+
module = Module(parent, "TestModule")
|
52
|
+
|
53
|
+
element = EcucParamConfContainerDef(module, "ChildElement")
|
54
|
+
module.addElement(element)
|
55
|
+
|
56
|
+
assert module.getTotalElement() == 1
|
57
|
+
assert module.getElement("ChildElement") == element
|
58
|
+
|
59
|
+
def test_module_remove_element(self):
|
60
|
+
root = EBModel.getInstance()
|
61
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
62
|
+
module = Module(parent, "TestModule")
|
63
|
+
|
64
|
+
element = EcucParamConfContainerDef(module, "ChildElement")
|
65
|
+
module.addElement(element)
|
66
|
+
|
67
|
+
assert module.getTotalElement() == 1
|
68
|
+
|
69
|
+
module.removeElement("ChildElement")
|
70
|
+
assert module.getTotalElement() == 0
|
71
|
+
assert module.getElement("ChildElement") is None
|
72
|
+
|
73
|
+
def test_module_get_full_name(self):
|
74
|
+
root = EBModel.getInstance()
|
75
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
76
|
+
module = Module(parent, "TestModule")
|
77
|
+
|
78
|
+
assert module.getFullName() == "/Parent/TestModule"
|
79
|
+
|
80
|
+
|
81
|
+
class TestEcucRefType:
|
82
|
+
|
83
|
+
def test_initialization(self):
|
84
|
+
ref = EcucRefType("/Parent/Child")
|
85
|
+
assert ref.getValue() == "/Parent/Child"
|
86
|
+
|
87
|
+
def test_set_value(self):
|
88
|
+
ref = EcucRefType("/Parent/Child")
|
89
|
+
ref.setValue("/NewParent/NewChild")
|
90
|
+
assert ref.getValue() == "/NewParent/NewChild"
|
91
|
+
|
92
|
+
def test_str_representation(self):
|
93
|
+
ref = EcucRefType("/Parent/Child")
|
94
|
+
assert str(ref) == "/Parent/Child"
|
95
|
+
|
96
|
+
def test_get_short_name_valid(self):
|
97
|
+
ref = EcucRefType("/Parent/Child")
|
98
|
+
assert ref.getShortName() == "Child"
|
99
|
+
|
100
|
+
def test_get_short_name_invalid(self):
|
101
|
+
ref = EcucRefType("InvalidValue")
|
102
|
+
assert ref.getShortName() == "InvalidValue"
|
103
|
+
|
104
|
+
def test_get_short_name_raises_error_on_none(self):
|
105
|
+
ref = EcucRefType(None)
|
106
|
+
with pytest.raises(ValueError, match="Invalid value of EcucRefType"):
|
107
|
+
ref.getShortName()
|
108
|
+
|
109
|
+
|
110
|
+
class TestEcucParamConfContainerDef:
|
111
|
+
|
112
|
+
def test_initialization(self):
|
113
|
+
root = EBModel.getInstance()
|
114
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
115
|
+
|
116
|
+
assert container.getName() == "TestContainer"
|
117
|
+
assert container.getParent() == root
|
118
|
+
assert container.getTotalElement() == 0
|
119
|
+
|
120
|
+
def test_add_element(self):
|
121
|
+
root = EBModel.getInstance()
|
122
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
123
|
+
child = EcucParamConfContainerDef(container, "ChildElement")
|
124
|
+
|
125
|
+
container.addElement(child)
|
126
|
+
|
127
|
+
assert container.getTotalElement() == 1
|
128
|
+
assert container.getElement("ChildElement") == child
|
129
|
+
|
130
|
+
def test_remove_element(self):
|
131
|
+
root = EBModel.getInstance()
|
132
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
133
|
+
child = EcucParamConfContainerDef(container, "ChildElement")
|
134
|
+
|
135
|
+
container.addElement(child)
|
136
|
+
assert container.getTotalElement() == 1
|
137
|
+
|
138
|
+
container.removeElement("ChildElement")
|
139
|
+
assert container.getTotalElement() == 0
|
140
|
+
assert container.getElement("ChildElement") is None
|
141
|
+
|
142
|
+
def test_remove_element_invalid_key(self):
|
143
|
+
root = EBModel.getInstance()
|
144
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
145
|
+
|
146
|
+
with pytest.raises(KeyError, match="Invalid key <InvalidKey> for removing element"):
|
147
|
+
container.removeElement("InvalidKey")
|
148
|
+
|
149
|
+
def test_get_element_list(self):
|
150
|
+
root = EBModel.getInstance()
|
151
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
152
|
+
child1 = EcucParamConfContainerDef(container, "Child1")
|
153
|
+
child2 = EcucParamConfContainerDef(container, "Child2")
|
154
|
+
|
155
|
+
container.addElement(child1)
|
156
|
+
container.addElement(child2)
|
157
|
+
|
158
|
+
element_list = list(container.getElementList())
|
159
|
+
assert len(element_list) == 2
|
160
|
+
assert child1 in element_list
|
161
|
+
assert child2 in element_list
|
162
|
+
|
163
|
+
def test_get_element_not_found(self):
|
164
|
+
root = EBModel.getInstance()
|
165
|
+
container = EcucParamConfContainerDef(root, "TestContainer")
|
166
|
+
|
167
|
+
assert container.getElement("NonExistent") is None
|
168
|
+
|
169
|
+
|
170
|
+
class TestEcucObject:
|
171
|
+
|
172
|
+
def test_initialization_raises_error(self):
|
173
|
+
root = EBModel.getInstance()
|
174
|
+
with pytest.raises(ValueError, match="Abstract EcucObject cannot be initialized."):
|
175
|
+
EcucObject(root, "AbstractObject")
|
176
|
+
|
177
|
+
def test_get_and_set_name(self):
|
178
|
+
root = EBModel.getInstance()
|
179
|
+
container = EcucParamConfContainerDef(root, "Parent")
|
180
|
+
obj = EcucEnumerationParamDef(container, "TestObject")
|
181
|
+
|
182
|
+
assert obj.getName() == "TestObject"
|
183
|
+
obj.setName("NewName")
|
184
|
+
assert obj.getName() == "NewName"
|
185
|
+
|
186
|
+
def test_get_and_set_parent(self):
|
187
|
+
root = EBModel.getInstance()
|
188
|
+
container1 = EcucParamConfContainerDef(root, "Parent1")
|
189
|
+
container2 = EcucParamConfContainerDef(root, "Parent2")
|
190
|
+
obj = EcucEnumerationParamDef(container1, "TestObject")
|
191
|
+
|
192
|
+
assert obj.getParent() == container1
|
193
|
+
obj.setParent(container2)
|
194
|
+
assert obj.getParent() == container2
|
195
|
+
|
196
|
+
def test_get_full_name(self):
|
197
|
+
root = EBModel.getInstance()
|
198
|
+
parent = EcucParamConfContainerDef(root, "Parent")
|
199
|
+
obj = EcucEnumerationParamDef(parent, "Child")
|
200
|
+
|
201
|
+
assert obj.getFullName() == "/Parent/Child"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import pytest
|
2
|
+
from ...models.eb_doc import EBModel, PreferenceModel
|
3
|
+
|
4
|
+
|
5
|
+
class TestEBModel:
|
6
|
+
|
7
|
+
def test_ebmodel_singleton_exception(self):
|
8
|
+
EBModel.getInstance()
|
9
|
+
with pytest.raises(Exception) as err:
|
10
|
+
EBModel()
|
11
|
+
assert (str(err.value) == "The EBModel is singleton!")
|
12
|
+
|
13
|
+
def test_cannot_find_element(self):
|
14
|
+
document = EBModel.getInstance()
|
15
|
+
assert (document.find("/os/os") is None)
|
16
|
+
|
17
|
+
def test_ebmodel(self):
|
18
|
+
document = EBModel.getInstance()
|
19
|
+
assert (isinstance(document, EBModel))
|
20
|
+
assert (isinstance(document, EBModel))
|
21
|
+
assert (document.getFullName() == "")
|
22
|
+
|
23
|
+
def test_clear(self):
|
24
|
+
document = EBModel.getInstance()
|
25
|
+
document.clear()
|
26
|
+
assert (document.getTotalElement() == 0)
|
27
|
+
document.getOs()
|
28
|
+
assert (document.getTotalElement() == 1)
|
29
|
+
document.clear()
|
30
|
+
assert (document.getTotalElement() == 0)
|
31
|
+
|
32
|
+
def test_ebmodel_get_os(self):
|
33
|
+
document = EBModel.getInstance()
|
34
|
+
os = document.getOs()
|
35
|
+
assert (os.getFullName() == "/Os/Os")
|
36
|
+
|
37
|
+
def test_ebmodel_get_rte(self):
|
38
|
+
document = EBModel.getInstance()
|
39
|
+
rte = document.getRte()
|
40
|
+
assert (rte.getFullName() == "/Rte/Rte")
|
41
|
+
|
42
|
+
def test_ebmodel_get_nvm(self):
|
43
|
+
document = EBModel.getInstance()
|
44
|
+
nvm = document.getNvM()
|
45
|
+
assert (nvm.getFullName() == "/NvM/NvM")
|
46
|
+
|
47
|
+
|
48
|
+
class TestPreferenceModel:
|
49
|
+
|
50
|
+
def test_preference_model_singleton_exception(self):
|
51
|
+
PreferenceModel.getInstance()
|
52
|
+
with pytest.raises(Exception) as err:
|
53
|
+
PreferenceModel()
|
54
|
+
assert (str(err.value) == "The PreferenceModel is singleton!")
|
55
|
+
|
56
|
+
def test_mode_get_system_description_importer(self):
|
57
|
+
document = PreferenceModel.getInstance()
|
58
|
+
importer = document.getSystemDescriptionImporter()
|
59
|
+
assert importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters"
|
60
|
+
|
61
|
+
importer = document.find(
|
62
|
+
"/ImporterExporterAdditions/SystemDescriptionImporters")
|
63
|
+
assert importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters"
|
64
|
+
|
65
|
+
importer = document.getSystemDescriptionImporter()
|
66
|
+
assert importer.getFullName() == "/ImporterExporterAdditions/SystemDescriptionImporters"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import pytest
|
2
|
+
from ...models.eclipse_project import Link
|
3
|
+
|
4
|
+
|
5
|
+
class TestLink:
|
6
|
+
|
7
|
+
def test_initialization(self):
|
8
|
+
link = Link("TestLink", "File", "file:///path/to/resource")
|
9
|
+
assert link.name == "TestLink"
|
10
|
+
assert link.type == "File"
|
11
|
+
assert link.locationURI == "file:///path/to/resource"
|
12
|
+
|
13
|
+
def test_set_attributes(self):
|
14
|
+
link = Link("InitialName", "Folder", "file:///initial/path")
|
15
|
+
link.name = "UpdatedName"
|
16
|
+
link.type = "File"
|
17
|
+
link.locationURI = "file:///updated/path"
|
18
|
+
|
19
|
+
assert link.name == "UpdatedName"
|
20
|
+
assert link.type == "File"
|
21
|
+
assert link.locationURI == "file:///updated/path"
|
@@ -8,54 +8,59 @@ class TestSystemDescriptionImporter:
|
|
8
8
|
def test_get_parsed_input_files(self):
|
9
9
|
document = PreferenceModel.getInstance()
|
10
10
|
importer = document.getSystemDescriptionImporter()
|
11
|
-
importer.addInputFile("${env_var:TRESOS_OUTPUT_DIR}
|
12
|
-
input_files = importer.getParsedInputFiles(
|
11
|
+
importer.addInputFile("${env_var:TRESOS_OUTPUT_DIR}\\**\\*.arxml")
|
12
|
+
input_files = importer.getParsedInputFiles(
|
13
|
+
{"env_var:TRESOS_OUTPUT_DIR": "c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd", "base_path": None})
|
14
|
+
|
15
|
+
assert len(input_files) == 1
|
16
|
+
assert input_files[0] == "c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd\\**\\*.arxml"
|
13
17
|
|
14
|
-
assert(len(input_files) == 1)
|
15
|
-
assert(input_files[0] == "c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd\\**\\*.arxml")
|
16
18
|
document = PreferenceModel.getInstance()
|
17
19
|
importer = document.getSystemDescriptionImporter()
|
18
20
|
path_segments = importer.getAllPaths("../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd")
|
19
|
-
assert
|
20
|
-
assert
|
21
|
-
assert
|
22
|
-
assert
|
23
|
-
assert
|
21
|
+
assert len(path_segments) == 7
|
22
|
+
assert path_segments[0] == "EB"
|
23
|
+
assert path_segments[1] == "EB/ACG-8_8_8_WIN32X86"
|
24
|
+
assert path_segments[2] == "EB/ACG-8_8_8_WIN32X86/workspace"
|
25
|
+
assert path_segments[6] == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd"
|
24
26
|
|
25
27
|
def test_get_links(self):
|
26
28
|
document = PreferenceModel.getInstance()
|
27
29
|
importer = document.getSystemDescriptionImporter()
|
28
30
|
file_list = []
|
29
|
-
file_list.append(
|
30
|
-
|
31
|
-
file_list.append(
|
31
|
+
file_list.append(
|
32
|
+
"../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
33
|
+
file_list.append(
|
34
|
+
"../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml")
|
35
|
+
file_list.append(
|
36
|
+
"../../EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml")
|
32
37
|
|
33
38
|
links = importer.getLinks(file_list)
|
34
|
-
assert
|
35
|
-
assert
|
36
|
-
assert
|
37
|
-
assert
|
38
|
-
|
39
|
-
assert
|
40
|
-
assert
|
41
|
-
assert
|
42
|
-
|
43
|
-
assert
|
44
|
-
assert
|
45
|
-
assert
|
46
|
-
|
47
|
-
assert
|
48
|
-
assert
|
49
|
-
assert
|
50
|
-
|
51
|
-
assert
|
52
|
-
assert
|
53
|
-
assert
|
54
|
-
|
55
|
-
assert
|
56
|
-
assert
|
57
|
-
assert
|
58
|
-
|
59
|
-
assert
|
60
|
-
assert
|
61
|
-
assert
|
39
|
+
assert len(links) == 9
|
40
|
+
assert links[0].name == "EB"
|
41
|
+
assert links[0].type == 2
|
42
|
+
assert links[0].locationURI == "virtual:/virtual"
|
43
|
+
|
44
|
+
assert links[1].name == "EB/ACG-8_8_8_WIN32X86"
|
45
|
+
assert links[1].type == 2
|
46
|
+
assert links[1].locationURI == "virtual:/virtual"
|
47
|
+
|
48
|
+
assert links[2].name == "EB/ACG-8_8_8_WIN32X86/workspace"
|
49
|
+
assert links[2].type == 2
|
50
|
+
assert links[2].locationURI == "virtual:/virtual"
|
51
|
+
|
52
|
+
assert links[3].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte"
|
53
|
+
assert links[3].type == 2
|
54
|
+
assert links[3].locationURI == "virtual:/virtual"
|
55
|
+
|
56
|
+
assert links[6].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd"
|
57
|
+
assert links[6].type == 2
|
58
|
+
assert links[6].locationURI == "virtual:/virtual"
|
59
|
+
|
60
|
+
assert links[7].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml"
|
61
|
+
assert links[7].type == 1
|
62
|
+
assert links[7].locationURI == "PARENT-2-PROJECT_LOC/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/Atomics_Bswmd.arxml" # noqa E501
|
63
|
+
|
64
|
+
assert links[8].name == "EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml"
|
65
|
+
assert links[8].type == 1
|
66
|
+
assert links[8].locationURI == "PARENT-2-PROJECT_LOC/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rte/output/generated/swcd/BswM.arxml"
|
File without changes
|
@@ -0,0 +1,150 @@
|
|
1
|
+
from ...parser.os_xdm_parser import OsXdmParser
|
2
|
+
from ...models.os_xdm import Os, OsResource
|
3
|
+
from ...models.eb_doc import EBModel
|
4
|
+
|
5
|
+
import xml.etree.ElementTree as ET
|
6
|
+
import pytest
|
7
|
+
|
8
|
+
|
9
|
+
class TestOsXdmParser:
|
10
|
+
def test_read_os_resources(self):
|
11
|
+
|
12
|
+
# Create a mock XML element for testing
|
13
|
+
xml_content = """
|
14
|
+
<datamodel version="8.0"
|
15
|
+
xmlns="http://www.tresos.de/_projects/DataModel2/18/root.xsd"
|
16
|
+
xmlns:a="http://www.tresos.de/_projects/DataModel2/18/attribute.xsd"
|
17
|
+
xmlns:v="http://www.tresos.de/_projects/DataModel2/06/schema.xsd"
|
18
|
+
xmlns:d="http://www.tresos.de/_projects/DataModel2/06/data.xsd">
|
19
|
+
<d:lst name="OsResource" type="MAP">
|
20
|
+
<d:ctr name="Resource1">
|
21
|
+
<a:a name="IMPORTER_INFO" value="@CALC(SvcAs,os.resources,1)"/>
|
22
|
+
<d:var name="OsResourceProperty" type="ENUMERATION" value="STANDARD">
|
23
|
+
<d:lst name="OsResourceAccessingApplication">
|
24
|
+
<d:ref type="REFERENCE" value="ASPath:/Os/Os/OsApplication_C0">
|
25
|
+
<a:a name="IMPORTER_INFO" value="@CALC(SvcAs,os.resources,1)"/>
|
26
|
+
</d:ref>
|
27
|
+
</d:lst>
|
28
|
+
</d:var>
|
29
|
+
</d:ctr>
|
30
|
+
<d:ctr name="Resource2">
|
31
|
+
<d:var name="OsResourceProperty" type="ENUMERATION" value="INTERNAL"/>
|
32
|
+
<d:lst name="OsResourceAccessingApplication"/>
|
33
|
+
<d:ref name="OsResourceLinkedResourceRef" type="REFERENCE" >
|
34
|
+
<a:a name="ENABLE" value="false"/>
|
35
|
+
<a:a name="IMPORTER_INFO" value="@DEF"/>
|
36
|
+
</d:ref>
|
37
|
+
</d:ctr>
|
38
|
+
</d:lst>
|
39
|
+
</datamodel>
|
40
|
+
"""
|
41
|
+
element = ET.fromstring(xml_content)
|
42
|
+
|
43
|
+
# Mock Os object
|
44
|
+
model = EBModel.getInstance()
|
45
|
+
os = model.getOs()
|
46
|
+
|
47
|
+
# Create parser instance
|
48
|
+
parser = OsXdmParser()
|
49
|
+
parser.nsmap = {
|
50
|
+
'': "http://www.tresos.de/_projects/DataModel2/18/root.xsd",
|
51
|
+
'a': "http://www.tresos.de/_projects/DataModel2/18/attribute.xsd",
|
52
|
+
'v': "http://www.tresos.de/_projects/DataModel2/06/schema.xsd",
|
53
|
+
'd': "http://www.tresos.de/_projects/DataModel2/06/data.xsd"
|
54
|
+
}
|
55
|
+
|
56
|
+
# Call the method
|
57
|
+
parser.read_os_resources(element, os)
|
58
|
+
|
59
|
+
# Assertions
|
60
|
+
resources = os.getOsResourceList()
|
61
|
+
assert len(resources) == 2
|
62
|
+
|
63
|
+
resource1 = resources[0]
|
64
|
+
assert resource1.getName() == "Resource1"
|
65
|
+
assert resource1.getImporterInfo() == "@CALC(SvcAs,os.resources,1)"
|
66
|
+
assert resource1.isCalculatedSvcAs() is True
|
67
|
+
assert resource1.getOsResourceProperty() == "STANDARD"
|
68
|
+
assert len(resource1.getOsResourceAccessingApplicationRefs()) == 1
|
69
|
+
for ref in resource1.getOsResourceAccessingApplicationRefs():
|
70
|
+
assert ref.getValue() == "/Os/Os/OsApplication_C0"
|
71
|
+
|
72
|
+
resource2 = resources[1]
|
73
|
+
assert resource2.getName() == "Resource2"
|
74
|
+
assert resource2.getImporterInfo() is None
|
75
|
+
assert resource2.isCalculatedSvcAs() is False
|
76
|
+
assert resource2.getOsResourceProperty() == "INTERNAL"
|
77
|
+
assert len(resource2.getOsResourceAccessingApplicationRefs()) == 0
|
78
|
+
|
79
|
+
'''
|
80
|
+
def test_read_os_applications(self):
|
81
|
+
# Create a mock XML element for testing
|
82
|
+
xml_content = """
|
83
|
+
<datamodel version="8.0"
|
84
|
+
xmlns="http://www.tresos.de/_projects/DataModel2/18/root.xsd"
|
85
|
+
xmlns:a="http://www.tresos.de/_projects/DataModel2/18/attribute.xsd"
|
86
|
+
xmlns:v="http://www.tresos.de/_projects/DataModel2/06/schema.xsd"
|
87
|
+
xmlns:d="http://www.tresos.de/_projects/DataModel2/06/data.xsd">
|
88
|
+
<d:lst name="OsApplication" type="MAP">
|
89
|
+
<d:ctr name="App1">
|
90
|
+
<d:var name="OsTrusted" type="BOOLEAN" value="true"/>
|
91
|
+
<d:lst name="OsAppResourceRef">
|
92
|
+
<d:ref type="REFERENCE" value="/Os/OsResource1"/>
|
93
|
+
<d:ref type="REFERENCE" value="/Os/OsResource2"/>
|
94
|
+
</d:lst>
|
95
|
+
<d:lst name="OsAppTaskRef">
|
96
|
+
<d:ref type="REFERENCE" value="/Os/OsTask1"/>
|
97
|
+
</d:lst>
|
98
|
+
<d:lst name="OsAppIsrRef">
|
99
|
+
<d:ref type="REFERENCE" value="/Os/OsIsr1"/>
|
100
|
+
</d:lst>
|
101
|
+
</d:ctr>
|
102
|
+
<d:ctr name="App2">
|
103
|
+
<d:var name="OsTrusted" type="BOOLEAN" value="false"/>
|
104
|
+
<d:lst name="OsAppResourceRef"/>
|
105
|
+
<d:lst name="OsAppTaskRef"/>
|
106
|
+
<d:lst name="OsAppIsrRef"/>
|
107
|
+
</d:ctr>
|
108
|
+
</d:lst>
|
109
|
+
</datamodel>
|
110
|
+
"""
|
111
|
+
element = ET.fromstring(xml_content)
|
112
|
+
|
113
|
+
# Mock Os object
|
114
|
+
model = EBModel.getInstance()
|
115
|
+
os = model.getOs()
|
116
|
+
|
117
|
+
# Create parser instance
|
118
|
+
parser = OsXdmParser()
|
119
|
+
parser.nsmap = {
|
120
|
+
'': "http://www.tresos.de/_projects/DataModel2/18/root.xsd",
|
121
|
+
'a': "http://www.tresos.de/_projects/DataModel2/18/attribute.xsd",
|
122
|
+
'v': "http://www.tresos.de/_projects/DataModel2/06/schema.xsd",
|
123
|
+
'd': "http://www.tresos.de/_projects/DataModel2/06/data.xsd"
|
124
|
+
}
|
125
|
+
|
126
|
+
# Call the method
|
127
|
+
parser.read_os_applications(element, os)
|
128
|
+
|
129
|
+
# Assertions
|
130
|
+
applications = os.getOsApplicationList()
|
131
|
+
assert len(applications) == 2
|
132
|
+
|
133
|
+
app1 = applications[0]
|
134
|
+
assert app1.getName() == "App1"
|
135
|
+
assert app1.getOsTrusted() == "true"
|
136
|
+
assert len(app1.getOsAppResourceRefs()) == 2
|
137
|
+
assert app1.getOsAppResourceRefs()[0].getValue() == "/Os/OsResource1"
|
138
|
+
assert app1.getOsAppResourceRefs()[1].getValue() == "/Os/OsResource2"
|
139
|
+
assert len(app1.getOsAppTaskRefs()) == 1
|
140
|
+
assert app1.getOsAppTaskRefs()[0].getValue() == "/Os/OsTask1"
|
141
|
+
assert len(app1.getOsAppIsrRefs()) == 1
|
142
|
+
assert app1.getOsAppIsrRefs()[0].getValue() == "/Os/OsIsr1"
|
143
|
+
|
144
|
+
app2 = applications[1]
|
145
|
+
assert app2.getName() == "App2"
|
146
|
+
assert app2.getOsTrusted() == "false"
|
147
|
+
assert len(app2.getOsAppResourceRefs()) == 0
|
148
|
+
assert len(app2.getOsAppTaskRefs()) == 0
|
149
|
+
assert len(app2.getOsAppIsrRefs()) == 0
|
150
|
+
noqa: E501 '''
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py-eb-model
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.7
|
4
4
|
Summary: The parser for EB XDM file
|
5
5
|
Home-page: UNKNOWN
|
6
6
|
Author: melodypapa
|
@@ -222,3 +222,9 @@ PrefSystemImporter --base-path c:/EB/ACG-8_8_8_WIN32X86/workspace/simple_demo_rt
|
|
222
222
|
* Os::addOsResource
|
223
223
|
2. Read the NvMBlockDescriptor List
|
224
224
|
|
225
|
+
**Version 1.1.7**
|
226
|
+
|
227
|
+
1. Solve the case issue of read_optional_value enables attribute.
|
228
|
+
2. Support to read IMPORT_INFO for OsResource.
|
229
|
+
3. Add the test cases for OsXdmParser.
|
230
|
+
|