armodel 1.3.0__py3-none-any.whl → 1.4.0__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.
- armodel/cli/connector2xlsx_cli.py +75 -0
- armodel/cli/connector_update_cli.py +70 -0
- armodel/cli/swc_list_cli.py +2 -2
- armodel/lib/__init__.py +1 -1
- armodel/lib/data_analyzer.py +1 -1
- armodel/lib/sw_component.py +34 -0
- armodel/models/__init__.py +6 -1
- armodel/models/ar_object.py +39 -0
- armodel/models/ar_package.py +35 -1
- armodel/models/ar_ref.py +12 -2
- armodel/models/bsw_module_template.py +3 -2
- armodel/models/calibration.py +16 -0
- armodel/models/common_structure.py +92 -0
- armodel/models/communication.py +8 -0
- armodel/models/datatype.py +23 -5
- armodel/models/general_structure.py +48 -3
- armodel/models/global_constraints.py +40 -0
- armodel/models/m2_msr.py +76 -2
- armodel/models/port_prototype.py +21 -16
- armodel/models/sw_component.py +47 -18
- armodel/models/unit.py +14 -0
- armodel/parser/arxml_parser.py +552 -120
- armodel/parser/excel_parser.py +0 -0
- armodel/report/__init__.py +1 -0
- armodel/report/connector_xls_report.py +76 -0
- armodel/report/excel_report.py +42 -0
- armodel/tests/__init__.py +0 -0
- armodel/tests/test_armodel/__init__.py +0 -0
- armodel/tests/test_armodel/models/__init__.py +0 -0
- armodel/tests/test_armodel/models/test_ar_package.py +294 -0
- armodel/tests/test_armodel/models/test_ar_ref.py +74 -0
- armodel/tests/test_armodel/models/test_bsw_module_template.py +46 -0
- armodel/tests/test_armodel/models/test_common_structure.py +73 -0
- armodel/tests/test_armodel/models/test_data_dictionary.py +29 -0
- armodel/tests/test_armodel/models/test_data_prototype.py +86 -0
- armodel/tests/test_armodel/models/test_datatype.py +239 -0
- armodel/tests/test_armodel/models/test_general_structure.py +50 -0
- armodel/tests/test_armodel/models/test_m2_msr.py +77 -0
- armodel/tests/test_armodel/models/test_port_interface.py +198 -0
- armodel/tests/test_armodel/models/test_port_prototype.py +14 -0
- armodel/tests/test_armodel/parser/__init__.py +0 -0
- armodel/tests/test_armodel/parser/test_parse_bswmd.py +168 -0
- armodel/writer/__init__.py +1 -0
- armodel/writer/arxml_writer.py +641 -0
- {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/METADATA +38 -5
- armodel-1.4.0.dist-info/RECORD +60 -0
- {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/WHEEL +1 -1
- armodel-1.4.0.dist-info/entry_points.txt +5 -0
- armodel-1.3.0.dist-info/RECORD +0 -31
- armodel-1.3.0.dist-info/entry_points.txt +0 -4
- {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/LICENSE +0 -0
- {armodel-1.3.0.dist-info → armodel-1.4.0.dist-info}/top_level.txt +0 -0
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .connector_xls_report import ConnectorXlsReport
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from .excel_report import ExcelReporter
|
|
2
|
+
from ..models import AUTOSAR, ARPackage, CompositionSwComponentType
|
|
3
|
+
from ..models import PPortInCompositionInstanceRef, RPortInCompositionInstanceRef
|
|
4
|
+
from typing import List
|
|
5
|
+
|
|
6
|
+
class ConnectorXlsReport(ExcelReporter):
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
super().__init__()
|
|
9
|
+
self.swcs = [] # type: List[CompositionSwComponentType]
|
|
10
|
+
|
|
11
|
+
def _parse_pkg(self, parent: ARPackage):
|
|
12
|
+
for pkg in parent.getARPackages():
|
|
13
|
+
self._parse_pkg(pkg)
|
|
14
|
+
for swc in parent.getSwComponentTypes():
|
|
15
|
+
self.swcs.append(swc)
|
|
16
|
+
|
|
17
|
+
def import_data(self, document: AUTOSAR):
|
|
18
|
+
for pkg in document.getARPackages():
|
|
19
|
+
self._parse_pkg(pkg)
|
|
20
|
+
|
|
21
|
+
def _write_assembly_sw_connection(self, swc: CompositionSwComponentType, index = 0):
|
|
22
|
+
sheet = self.wb.create_sheet("%s - AC" % swc.short_name, index)
|
|
23
|
+
title_row = ["Short Name", "Provide SW-C", "PPort", "Request SW-C", "RPort"]
|
|
24
|
+
self.write_title_row(sheet, title_row)
|
|
25
|
+
|
|
26
|
+
row = 2
|
|
27
|
+
for connector in swc.getAssemblySwConnectors():
|
|
28
|
+
self._logger.debug("Write AssemblySwConnection %s" % connector.short_name)
|
|
29
|
+
self.write_cell(sheet, row, 1, connector.short_name)
|
|
30
|
+
self.write_cell(sheet, row, 2, connector.provider_iref.context_component_ref.value)
|
|
31
|
+
self.write_cell(sheet, row, 3, connector.provider_iref.target_p_port_ref.value)
|
|
32
|
+
self.write_cell(sheet, row, 4, connector.requester_iref.context_component_ref.value)
|
|
33
|
+
self.write_cell(sheet, row, 5, connector.requester_iref.target_r_port_ref.value)
|
|
34
|
+
row += 1
|
|
35
|
+
|
|
36
|
+
self.auto_width(sheet)
|
|
37
|
+
|
|
38
|
+
def _write_delegation_sw_connection(self, swc: CompositionSwComponentType, index = 0):
|
|
39
|
+
sheet = self.wb.create_sheet("%s - DC" % swc.short_name, index)
|
|
40
|
+
title_row = ["Short Name", "Inner SW-C", "Inner PPort", "Outer PPort", "Inner RPort", "Outer RPort"]
|
|
41
|
+
self.write_title_row(sheet, title_row)
|
|
42
|
+
|
|
43
|
+
row = 2
|
|
44
|
+
for connector in swc.getDelegationSwConnectors():
|
|
45
|
+
self._logger.debug("Write DelegationSwConnection %s" % connector.short_name)
|
|
46
|
+
self.write_cell(sheet, row, 1, connector.short_name)
|
|
47
|
+
|
|
48
|
+
if connector.inner_port_iref:
|
|
49
|
+
if isinstance(connector.inner_port_iref, PPortInCompositionInstanceRef):
|
|
50
|
+
self.write_cell(sheet, row, 2, connector.inner_port_iref.context_component_ref.value)
|
|
51
|
+
self.write_cell(sheet, row, 3, connector.inner_port_iref.target_p_port_ref.value)
|
|
52
|
+
elif isinstance(connector.inner_port_iref, RPortInCompositionInstanceRef):
|
|
53
|
+
self.write_cell(sheet, row, 2, connector.inner_port_iref.context_component_ref.value)
|
|
54
|
+
self.write_cell(sheet, row, 5, connector.inner_port_iref.target_r_port_ref.value)
|
|
55
|
+
|
|
56
|
+
if connector.outer_port_ref.dest == "P-PORT-PROTOTYPE":
|
|
57
|
+
self.write_cell(sheet, row, 4, connector.outer_port_ref.value)
|
|
58
|
+
elif connector.outer_port_ref.dest == "R-PORT-PROTOTYPE":
|
|
59
|
+
self.write_cell(sheet, row, 6, connector.outer_port_ref.value)
|
|
60
|
+
else:
|
|
61
|
+
raise ValueError("Invalid OUTER-PORT-REF of SwConnector <%s>" % connector.short_name)
|
|
62
|
+
row += 1
|
|
63
|
+
|
|
64
|
+
self.auto_width(sheet)
|
|
65
|
+
|
|
66
|
+
def write(self, filename: str):
|
|
67
|
+
swc_list = filter(lambda o: isinstance(o, CompositionSwComponentType), self.swcs)
|
|
68
|
+
|
|
69
|
+
idx = 1
|
|
70
|
+
for swc in sorted(swc_list, key = lambda o: o.short_name):
|
|
71
|
+
self._logger.info("CompositionSwComponentType %s" % swc.short_name)
|
|
72
|
+
self._write_assembly_sw_connection(swc, idx)
|
|
73
|
+
self._write_delegation_sw_connection(swc, idx + 1)
|
|
74
|
+
idx += 2
|
|
75
|
+
|
|
76
|
+
self.wb.save(filename)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from openpyxl import Workbook
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
class ExcelReporter:
|
|
6
|
+
def __init__(self) -> None:
|
|
7
|
+
self.wb = Workbook()
|
|
8
|
+
self._logger = logging.getLogger()
|
|
9
|
+
|
|
10
|
+
def write_revision(self):
|
|
11
|
+
sheet = self.wb['Sheet']
|
|
12
|
+
sheet.title = "History"
|
|
13
|
+
|
|
14
|
+
title_rows = ["When", "Who", "Version", "History"]
|
|
15
|
+
self.write_title_row(sheet, title_rows)
|
|
16
|
+
|
|
17
|
+
def auto_width(self, worksheet):
|
|
18
|
+
dims = {}
|
|
19
|
+
for row in worksheet.rows:
|
|
20
|
+
for cell in row:
|
|
21
|
+
if cell.value:
|
|
22
|
+
dims[cell.column_letter] = max((dims.get(cell.column_letter, 0), len(str(cell.value))))
|
|
23
|
+
|
|
24
|
+
for col, value in dims.items():
|
|
25
|
+
worksheet.column_dimensions[col].width = (value + 2) + 2
|
|
26
|
+
|
|
27
|
+
def write_title_row(self, sheet, title_row):
|
|
28
|
+
for idx in range(0, len(title_row)):
|
|
29
|
+
cell = sheet.cell(row=1, column=idx + 1)
|
|
30
|
+
cell.value = title_row[idx]
|
|
31
|
+
|
|
32
|
+
def write_cell(self, sheet, row, column, value, format = None):
|
|
33
|
+
cell = sheet.cell(row = row, column=column)
|
|
34
|
+
cell.value = value
|
|
35
|
+
if (format != None):
|
|
36
|
+
if ('alignment' in format):
|
|
37
|
+
cell.alignment = format['alignment']
|
|
38
|
+
if ('number_format' in format):
|
|
39
|
+
cell.number_format = format['number_format']
|
|
40
|
+
|
|
41
|
+
def save(self, name: str):
|
|
42
|
+
self.wb.save(name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
""" Test AR Package """
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from ....models.ar_package import AUTOSAR
|
|
5
|
+
from ....models.datatype import ApplicationPrimitiveDataType, ApplicationRecordDataType, DataTypeMappingSet, ImplementationDataType, SwBaseType
|
|
6
|
+
from ....models.general_structure import ARElement, ARObject, CollectableElement, Identifiable, MultilanguageReferrable, PackageableElement, Referrable
|
|
7
|
+
from ....models.m2_msr import CompuMethod
|
|
8
|
+
from ....models.port_interface import ClientServerInterface, DataInterface, PortInterface, SenderReceiverInterface
|
|
9
|
+
from ....models.sw_component import ApplicationSwComponentType, AtomicSwComponentType, CompositionSwComponentType, EcuAbstractionSwComponentType, ServiceSwComponentType, SwComponentType
|
|
10
|
+
|
|
11
|
+
class TestAUTOSAR:
|
|
12
|
+
|
|
13
|
+
def test_autosar_singleton_exception(self):
|
|
14
|
+
AUTOSAR.getInstance()
|
|
15
|
+
with pytest.raises(Exception) as err:
|
|
16
|
+
AUTOSAR()
|
|
17
|
+
assert(str(err.value) == "The AUTOSAR is singleton!")
|
|
18
|
+
|
|
19
|
+
def test_cannot_find_element(self):
|
|
20
|
+
document = AUTOSAR.getInstance()
|
|
21
|
+
#with pytest.raises(Exception) as err:
|
|
22
|
+
# document.find("/sw_package/not_found")
|
|
23
|
+
#assert(str(err.value) ==
|
|
24
|
+
# "The sw_package of reference </sw_package/not_found> does not exist.")
|
|
25
|
+
assert(document.find("/sw_package/not_found") == None)
|
|
26
|
+
|
|
27
|
+
def test_autosar(self):
|
|
28
|
+
document = AUTOSAR.getInstance()
|
|
29
|
+
assert (isinstance(document, CollectableElement))
|
|
30
|
+
assert (isinstance(document, AUTOSAR))
|
|
31
|
+
assert (len(document.getARPackages()) == 0)
|
|
32
|
+
assert (document.version == "4.3.0")
|
|
33
|
+
assert (document.full_name == "")
|
|
34
|
+
|
|
35
|
+
def test_create_autosar_package(self):
|
|
36
|
+
document = AUTOSAR.getInstance()
|
|
37
|
+
ar_package = document.createARPackage("sw_package")
|
|
38
|
+
assert ("sw_package" == ar_package.short_name)
|
|
39
|
+
assert (len(document.getARPackages()) == 1)
|
|
40
|
+
assert (document.getARPackages()[0] == ar_package)
|
|
41
|
+
|
|
42
|
+
ar_package = document.find("/sw_package")
|
|
43
|
+
assert ("sw_package" == ar_package.short_name)
|
|
44
|
+
|
|
45
|
+
assert(isinstance(ar_package, ARObject))
|
|
46
|
+
assert(isinstance(ar_package, Identifiable))
|
|
47
|
+
assert(isinstance(ar_package, Referrable))
|
|
48
|
+
assert(isinstance(ar_package, MultilanguageReferrable))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class TestARPackage:
|
|
52
|
+
|
|
53
|
+
def test_create_autosar_package(self):
|
|
54
|
+
document = AUTOSAR.getInstance()
|
|
55
|
+
ar_package_level1 = document.createARPackage("package_level1")
|
|
56
|
+
assert (ar_package_level1.short_name == "package_level1")
|
|
57
|
+
assert (ar_package_level1.full_name == "/package_level1")
|
|
58
|
+
assert (len(ar_package_level1.getARPackages()) == 0)
|
|
59
|
+
|
|
60
|
+
ar_find_package = document.find("/package_level1")
|
|
61
|
+
assert (ar_find_package == ar_package_level1)
|
|
62
|
+
assert (ar_find_package.short_name == 'package_level1')
|
|
63
|
+
|
|
64
|
+
ar_package_level2 = ar_package_level1.createARPackage("package_level2")
|
|
65
|
+
assert (ar_package_level2.short_name == 'package_level2')
|
|
66
|
+
assert (ar_package_level2.full_name ==
|
|
67
|
+
"/package_level1/package_level2")
|
|
68
|
+
assert (len(ar_package_level1.getARPackages()) == 1)
|
|
69
|
+
assert (ar_package_level1.getARPackages()[0] == ar_package_level2)
|
|
70
|
+
|
|
71
|
+
ar_find_package = document.find("/package_level1/package_level2")
|
|
72
|
+
assert (ar_find_package == ar_package_level2)
|
|
73
|
+
assert (ar_find_package.short_name == "package_level2")
|
|
74
|
+
|
|
75
|
+
def test_createEcuAbstractionSwComponentType(self):
|
|
76
|
+
document = AUTOSAR.getInstance()
|
|
77
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
78
|
+
sw_component_type = ar_root.createEcuAbstractionSwComponentType(
|
|
79
|
+
"ecu_abstract_sw_component")
|
|
80
|
+
assert(sw_component_type.short_name == "ecu_abstract_sw_component")
|
|
81
|
+
assert(isinstance(sw_component_type, EcuAbstractionSwComponentType))
|
|
82
|
+
|
|
83
|
+
find_component_type = document.find(
|
|
84
|
+
"/AUTOSAR/ecu_abstract_sw_component")
|
|
85
|
+
assert (find_component_type == sw_component_type)
|
|
86
|
+
assert (find_component_type.short_name == "ecu_abstract_sw_component")
|
|
87
|
+
|
|
88
|
+
def test_createApplicationSwComponentType(self):
|
|
89
|
+
document = AUTOSAR.getInstance()
|
|
90
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
91
|
+
sw_component_type = ar_root.createApplicationSwComponentType(
|
|
92
|
+
"application_sw_component")
|
|
93
|
+
assert(sw_component_type.short_name == "application_sw_component")
|
|
94
|
+
|
|
95
|
+
assert(isinstance(sw_component_type, ARElement))
|
|
96
|
+
assert(isinstance(sw_component_type, AtomicSwComponentType))
|
|
97
|
+
assert(isinstance(sw_component_type, CollectableElement))
|
|
98
|
+
assert(isinstance(sw_component_type, Identifiable))
|
|
99
|
+
assert(isinstance(sw_component_type, MultilanguageReferrable))
|
|
100
|
+
assert(isinstance(sw_component_type, PackageableElement))
|
|
101
|
+
assert(isinstance(sw_component_type, Referrable))
|
|
102
|
+
assert(isinstance(sw_component_type, SwComponentType))
|
|
103
|
+
assert(isinstance(sw_component_type, ApplicationSwComponentType))
|
|
104
|
+
|
|
105
|
+
find_component_type = document.find(
|
|
106
|
+
"/AUTOSAR/application_sw_component")
|
|
107
|
+
assert (find_component_type == sw_component_type)
|
|
108
|
+
assert (find_component_type.short_name == "application_sw_component")
|
|
109
|
+
|
|
110
|
+
def test_createServiceSwComponentType(self):
|
|
111
|
+
document = AUTOSAR.getInstance()
|
|
112
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
113
|
+
sw_component_type = ar_root.createServiceSwComponentType(
|
|
114
|
+
"service_sw_component")
|
|
115
|
+
assert(sw_component_type.short_name == "service_sw_component")
|
|
116
|
+
|
|
117
|
+
assert(isinstance(sw_component_type, ARElement))
|
|
118
|
+
assert(isinstance(sw_component_type, AtomicSwComponentType))
|
|
119
|
+
assert(isinstance(sw_component_type, CollectableElement))
|
|
120
|
+
assert(isinstance(sw_component_type, Identifiable))
|
|
121
|
+
assert(isinstance(sw_component_type, MultilanguageReferrable))
|
|
122
|
+
assert(isinstance(sw_component_type, PackageableElement))
|
|
123
|
+
assert(isinstance(sw_component_type, Referrable))
|
|
124
|
+
assert(isinstance(sw_component_type, SwComponentType))
|
|
125
|
+
assert(isinstance(sw_component_type, ServiceSwComponentType))
|
|
126
|
+
|
|
127
|
+
find_component_type = document.find("/AUTOSAR/service_sw_component")
|
|
128
|
+
assert (find_component_type == sw_component_type)
|
|
129
|
+
assert (find_component_type.short_name == "service_sw_component")
|
|
130
|
+
|
|
131
|
+
def test_createCompositionSwComponentType(self):
|
|
132
|
+
document = AUTOSAR.getInstance()
|
|
133
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
134
|
+
sw_component_type = ar_root.createCompositionSwComponentType(
|
|
135
|
+
"composition_sw_component")
|
|
136
|
+
assert(sw_component_type.short_name == "composition_sw_component")
|
|
137
|
+
|
|
138
|
+
assert(isinstance(sw_component_type, ARElement))
|
|
139
|
+
assert(isinstance(sw_component_type, CollectableElement))
|
|
140
|
+
assert(isinstance(sw_component_type, Identifiable))
|
|
141
|
+
assert(isinstance(sw_component_type, MultilanguageReferrable))
|
|
142
|
+
assert(isinstance(sw_component_type, PackageableElement))
|
|
143
|
+
assert(isinstance(sw_component_type, Referrable))
|
|
144
|
+
assert(isinstance(sw_component_type, SwComponentType))
|
|
145
|
+
assert(isinstance(sw_component_type, CompositionSwComponentType))
|
|
146
|
+
|
|
147
|
+
find_component_type = document.find(
|
|
148
|
+
"/AUTOSAR/composition_sw_component")
|
|
149
|
+
assert (find_component_type == sw_component_type)
|
|
150
|
+
assert (find_component_type.short_name == "composition_sw_component")
|
|
151
|
+
|
|
152
|
+
def test_createSenderReceiverInterface(self):
|
|
153
|
+
document = AUTOSAR.getInstance()
|
|
154
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
155
|
+
instance_if = ar_root.createSenderReceiverInterface(
|
|
156
|
+
"sender_receiver_interface")
|
|
157
|
+
assert(instance_if.short_name == "sender_receiver_interface")
|
|
158
|
+
|
|
159
|
+
assert(isinstance(instance_if, ARElement))
|
|
160
|
+
assert(isinstance(instance_if, CollectableElement))
|
|
161
|
+
assert(isinstance(instance_if, DataInterface))
|
|
162
|
+
assert(isinstance(instance_if, Identifiable))
|
|
163
|
+
assert(isinstance(instance_if, MultilanguageReferrable))
|
|
164
|
+
assert(isinstance(instance_if, PackageableElement))
|
|
165
|
+
assert(isinstance(instance_if, PortInterface))
|
|
166
|
+
assert(isinstance(instance_if, Referrable))
|
|
167
|
+
assert(isinstance(instance_if, SenderReceiverInterface))
|
|
168
|
+
|
|
169
|
+
find_component = document.find("/AUTOSAR/sender_receiver_interface")
|
|
170
|
+
assert (find_component == instance_if)
|
|
171
|
+
assert (find_component.short_name == "sender_receiver_interface")
|
|
172
|
+
|
|
173
|
+
assert (len(ar_root.getSenderReceiverInterfaces()) == 1)
|
|
174
|
+
assert (ar_root.getSenderReceiverInterfaces()[0] == instance_if)
|
|
175
|
+
assert (ar_root.getSenderReceiverInterfaces()[
|
|
176
|
+
0].short_name == "sender_receiver_interface")
|
|
177
|
+
|
|
178
|
+
def test_createClientServerInterface(self):
|
|
179
|
+
document = AUTOSAR.getInstance()
|
|
180
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
181
|
+
instance_if = ar_root.createClientServerInterface(
|
|
182
|
+
"client_server_interface")
|
|
183
|
+
assert(instance_if.short_name == "client_server_interface")
|
|
184
|
+
assert(isinstance(instance_if, ClientServerInterface))
|
|
185
|
+
|
|
186
|
+
find_component = document.find("/AUTOSAR/client_server_interface")
|
|
187
|
+
assert (find_component == instance_if)
|
|
188
|
+
assert (find_component.short_name == "client_server_interface")
|
|
189
|
+
|
|
190
|
+
assert (len(ar_root.getClientServerInterfaces()) == 1)
|
|
191
|
+
assert (ar_root.getClientServerInterfaces()[0] == instance_if)
|
|
192
|
+
assert (ar_root.getClientServerInterfaces()[
|
|
193
|
+
0].short_name == "client_server_interface")
|
|
194
|
+
|
|
195
|
+
def test_createApplicationPrimitiveDataType(self):
|
|
196
|
+
document = AUTOSAR.getInstance()
|
|
197
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
198
|
+
data_type = ar_root.createApplicationPrimitiveDataType(
|
|
199
|
+
"application_primitive_data_type")
|
|
200
|
+
assert(data_type.short_name == "application_primitive_data_type")
|
|
201
|
+
assert(isinstance(data_type, ApplicationPrimitiveDataType))
|
|
202
|
+
|
|
203
|
+
find_component = document.find(
|
|
204
|
+
"/AUTOSAR/application_primitive_data_type")
|
|
205
|
+
assert (find_component == data_type)
|
|
206
|
+
assert (find_component.short_name == "application_primitive_data_type")
|
|
207
|
+
|
|
208
|
+
assert (len(ar_root.getApplicationPrimitiveDataTypes()) == 1)
|
|
209
|
+
assert (ar_root.getApplicationPrimitiveDataTypes()[0] == data_type)
|
|
210
|
+
assert (ar_root.getApplicationPrimitiveDataTypes()[
|
|
211
|
+
0].short_name == "application_primitive_data_type")
|
|
212
|
+
|
|
213
|
+
def test_createApplicationRecordDataType(self):
|
|
214
|
+
document = AUTOSAR.getInstance()
|
|
215
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
216
|
+
data_type = ar_root.createApplicationRecordDataType(
|
|
217
|
+
"application_record_data_type")
|
|
218
|
+
assert(data_type.short_name == "application_record_data_type")
|
|
219
|
+
assert(isinstance(data_type, ApplicationRecordDataType))
|
|
220
|
+
|
|
221
|
+
find_component = document.find("/AUTOSAR/application_record_data_type")
|
|
222
|
+
assert (find_component == data_type)
|
|
223
|
+
assert (find_component.short_name == "application_record_data_type")
|
|
224
|
+
|
|
225
|
+
def test_createImplementationDataType(self):
|
|
226
|
+
document = AUTOSAR.getInstance()
|
|
227
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
228
|
+
data_type = ar_root.createImplementationDataType(
|
|
229
|
+
"implementation_data_type")
|
|
230
|
+
assert(data_type.short_name == "implementation_data_type")
|
|
231
|
+
assert(isinstance(data_type, ImplementationDataType))
|
|
232
|
+
|
|
233
|
+
find_component = document.find("/AUTOSAR/implementation_data_type")
|
|
234
|
+
assert (find_component == data_type)
|
|
235
|
+
assert (find_component.short_name == "implementation_data_type")
|
|
236
|
+
|
|
237
|
+
assert (len(ar_root.getImplementationDataTypes()) == 1)
|
|
238
|
+
assert (ar_root.getImplementationDataTypes()[0] == data_type)
|
|
239
|
+
assert (ar_root.getImplementationDataTypes()[
|
|
240
|
+
0].short_name == "implementation_data_type")
|
|
241
|
+
|
|
242
|
+
def test_createSwBaseType(self):
|
|
243
|
+
document = AUTOSAR.getInstance()
|
|
244
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
245
|
+
data_type = ar_root.createSwBaseType("sw_base_type")
|
|
246
|
+
assert(data_type.short_name == "sw_base_type")
|
|
247
|
+
assert(isinstance(data_type, SwBaseType))
|
|
248
|
+
|
|
249
|
+
find_component = document.find("/AUTOSAR/sw_base_type")
|
|
250
|
+
assert (find_component == data_type)
|
|
251
|
+
assert (find_component.short_name == "sw_base_type")
|
|
252
|
+
|
|
253
|
+
assert (len(ar_root.getSwBaseTypes()) == 1)
|
|
254
|
+
assert (ar_root.getSwBaseTypes()[0] == data_type)
|
|
255
|
+
assert (ar_root.getSwBaseTypes()[0].short_name == "sw_base_type")
|
|
256
|
+
|
|
257
|
+
def test_createDataTypeMappingSet(self):
|
|
258
|
+
document = AUTOSAR.getInstance()
|
|
259
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
260
|
+
mapping_set = ar_root.createDataTypeMappingSet("data_type_mapping_set")
|
|
261
|
+
assert(mapping_set.short_name == "data_type_mapping_set")
|
|
262
|
+
assert(isinstance(mapping_set, DataTypeMappingSet))
|
|
263
|
+
|
|
264
|
+
find_component = document.find("/AUTOSAR/data_type_mapping_set")
|
|
265
|
+
assert (find_component == mapping_set)
|
|
266
|
+
assert (find_component.short_name == "data_type_mapping_set")
|
|
267
|
+
|
|
268
|
+
assert (len(ar_root.getDataTypeMappingSets()) == 1)
|
|
269
|
+
assert (ar_root.getDataTypeMappingSets()[0] == mapping_set)
|
|
270
|
+
assert (ar_root.getDataTypeMappingSets()[
|
|
271
|
+
0].short_name == "data_type_mapping_set")
|
|
272
|
+
|
|
273
|
+
def test_createCompuMethod(self):
|
|
274
|
+
document = AUTOSAR.getInstance()
|
|
275
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
276
|
+
compu_method = ar_root.createCompuMethod("compu_method")
|
|
277
|
+
assert(compu_method.short_name == "compu_method")
|
|
278
|
+
assert(isinstance(compu_method, CompuMethod))
|
|
279
|
+
|
|
280
|
+
find_component = document.find("/AUTOSAR/compu_method")
|
|
281
|
+
assert (find_component == compu_method)
|
|
282
|
+
assert (find_component.short_name == "compu_method")
|
|
283
|
+
|
|
284
|
+
assert (len(ar_root.getCompuMethods()) == 1)
|
|
285
|
+
assert (ar_root.getCompuMethods()[0] == compu_method)
|
|
286
|
+
assert (ar_root.getCompuMethods()[0].short_name == "compu_method")
|
|
287
|
+
|
|
288
|
+
def test_getSwComponentTypes(self):
|
|
289
|
+
document = AUTOSAR.getInstance()
|
|
290
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
291
|
+
|
|
292
|
+
assert (len(ar_root.getSwComponentTypes()) == 4)
|
|
293
|
+
assert (len(ar_root.getAtomicSwComponentTypes()) == 3)
|
|
294
|
+
assert (len(ar_root.getCompositionSwComponentTypes()) == 1)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
""" Test ARRef """
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from ....models.ar_ref import ArVariableInImplementationDataInstanceRef, AutosarVariableRef, PPortInCompositionInstanceRef, RPortInCompositionInstanceRef
|
|
6
|
+
from ....models.ar_ref import OperationInAtomicSwcInstanceRef, POperationInAtomicSwcInstanceRef, ROperationInAtomicSwcInstanceRef, RefType, TRefType, AtpInstanceRef
|
|
7
|
+
from ....models.general_structure import ARObject
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestARRef:
|
|
11
|
+
def test_RefType(self):
|
|
12
|
+
ref_type = RefType()
|
|
13
|
+
assert(ref_type.value == "")
|
|
14
|
+
assert(ref_type.dest == "")
|
|
15
|
+
|
|
16
|
+
def test_TRefType(self):
|
|
17
|
+
ref_type = TRefType()
|
|
18
|
+
assert(ref_type.value == "")
|
|
19
|
+
assert(ref_type.dest == "")
|
|
20
|
+
|
|
21
|
+
def test_AutosarVariableRef(self):
|
|
22
|
+
ref_type = AutosarVariableRef()
|
|
23
|
+
assert(ref_type != None)
|
|
24
|
+
assert(ref_type.autosar_variable_iref == None)
|
|
25
|
+
assert(ref_type.autosar_variable_in_impl_datatype == None)
|
|
26
|
+
assert(ref_type.local_variable_ref == None)
|
|
27
|
+
|
|
28
|
+
def test_AtpInstanceRef(self):
|
|
29
|
+
with pytest.raises(NotImplementedError) as err:
|
|
30
|
+
ref_type = AtpInstanceRef()
|
|
31
|
+
assert(str(err.value) == "AtpInstanceRef is an abstract class.")
|
|
32
|
+
|
|
33
|
+
def test_ProvidedPortPrototypeInstanceRef(self):
|
|
34
|
+
ref_type = PPortInCompositionInstanceRef()
|
|
35
|
+
assert(ref_type != None)
|
|
36
|
+
assert(ref_type.context_component_ref == None)
|
|
37
|
+
assert(ref_type.target_p_port_ref == None)
|
|
38
|
+
|
|
39
|
+
def test_RequiredPortPrototypeInstanceRef(self):
|
|
40
|
+
ref_type = RPortInCompositionInstanceRef()
|
|
41
|
+
assert(ref_type != None)
|
|
42
|
+
assert(ref_type.context_component_ref == None)
|
|
43
|
+
assert(ref_type.target_r_port_ref == None)
|
|
44
|
+
|
|
45
|
+
def test_ArVariableInImplementationDataInstanceRef(self):
|
|
46
|
+
ref_type = ArVariableInImplementationDataInstanceRef()
|
|
47
|
+
assert(ref_type != None)
|
|
48
|
+
assert(ref_type.port_prototype_ref == None)
|
|
49
|
+
assert(ref_type.target_data_prototype_ref == None)
|
|
50
|
+
|
|
51
|
+
def test_OperationInAtomicSwcInstanceRef(self):
|
|
52
|
+
with pytest.raises(NotImplementedError) as err:
|
|
53
|
+
ref_type = OperationInAtomicSwcInstanceRef()
|
|
54
|
+
assert(str(err.value) == "OperationInAtomicSwcInstanceRef is an abstract class.")
|
|
55
|
+
|
|
56
|
+
def test_POperationInAtomicSwcInstanceRef(self):
|
|
57
|
+
ref_type = POperationInAtomicSwcInstanceRef()
|
|
58
|
+
assert(isinstance(ref_type, ARObject))
|
|
59
|
+
assert(isinstance(ref_type, AtpInstanceRef))
|
|
60
|
+
assert(isinstance(ref_type, OperationInAtomicSwcInstanceRef))
|
|
61
|
+
assert(isinstance(ref_type, POperationInAtomicSwcInstanceRef))
|
|
62
|
+
assert(ref_type != None)
|
|
63
|
+
assert(ref_type.context_p_port_ref == None)
|
|
64
|
+
assert(ref_type.target_provided_operation_ref == None)
|
|
65
|
+
|
|
66
|
+
def test_ROperationInAtomicSwcInstanceRef(self):
|
|
67
|
+
ref_type = ROperationInAtomicSwcInstanceRef()
|
|
68
|
+
assert(isinstance(ref_type, ARObject))
|
|
69
|
+
assert(isinstance(ref_type, AtpInstanceRef))
|
|
70
|
+
assert(isinstance(ref_type, OperationInAtomicSwcInstanceRef))
|
|
71
|
+
assert(isinstance(ref_type, ROperationInAtomicSwcInstanceRef))
|
|
72
|
+
assert(ref_type != None)
|
|
73
|
+
assert(ref_type.context_r_port_ref == None)
|
|
74
|
+
assert(ref_type.target_required_operation_ref == None)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from ....models.bsw_module_template import BswModuleDescription, BswModuleEntry, BswModuleEntity, BswCalledEntity
|
|
4
|
+
from .... import AUTOSAR
|
|
5
|
+
|
|
6
|
+
class TestBswModuleDescription:
|
|
7
|
+
def test_construct(self):
|
|
8
|
+
document = AUTOSAR.getInstance()
|
|
9
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
10
|
+
bsw_module_description = BswModuleDescription(ar_root, "bsw_module")
|
|
11
|
+
assert(bsw_module_description != None)
|
|
12
|
+
assert(bsw_module_description.short_name == "bsw_module")
|
|
13
|
+
|
|
14
|
+
def test_category(self):
|
|
15
|
+
document = AUTOSAR.getInstance()
|
|
16
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
17
|
+
bsw_module_description = BswModuleDescription(ar_root, "bsw_module")
|
|
18
|
+
with pytest.raises(ValueError) as err:
|
|
19
|
+
bsw_module_description.category = "invalid"
|
|
20
|
+
assert(str(err.value) == "Invalid category <invalid> of BswModuleDescription <bsw_module>")
|
|
21
|
+
|
|
22
|
+
bsw_module_description.category = "BSW_MODULE"
|
|
23
|
+
assert(bsw_module_description.category == "BSW_MODULE")
|
|
24
|
+
|
|
25
|
+
class Test_M2_AUTOSARTemplates_BswModuleTemplate_BswInterfaces:
|
|
26
|
+
def test_BswModuleEntry(self):
|
|
27
|
+
document = AUTOSAR.getInstance()
|
|
28
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
29
|
+
entry = BswModuleEntry(ar_root, "bsw_entry")
|
|
30
|
+
assert(entry != None)
|
|
31
|
+
assert(entry.short_name == "bsw_entry")
|
|
32
|
+
|
|
33
|
+
class Test_M2_AUTOSARTemplates_BswModuleTemplate_BswBehavior:
|
|
34
|
+
def test_BswModuleEntity(self):
|
|
35
|
+
document = AUTOSAR.getInstance()
|
|
36
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
37
|
+
with pytest.raises(NotImplementedError) as err:
|
|
38
|
+
BswModuleEntity(ar_root, "BswModuleEntity")
|
|
39
|
+
assert(str(err.value) == "BswModuleEntity is an abstract class.")
|
|
40
|
+
|
|
41
|
+
def test_BswCalledEntity(self):
|
|
42
|
+
document = AUTOSAR.getInstance()
|
|
43
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
44
|
+
entity = BswCalledEntity(ar_root, "bsw_called_entity")
|
|
45
|
+
assert(entity != None)
|
|
46
|
+
assert(entity.short_name == "bsw_called_entity")
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from .... import AUTOSAR
|
|
4
|
+
from ....models.common_structure import AbstractImplementationDataTypeElement, ConstantReference, ImplementationDataTypeElement, ValueSpecification, ConstantSpecification, ExecutableEntity
|
|
5
|
+
from ....models.datatype import AbstractImplementationDataType
|
|
6
|
+
from ....models.general_structure import ARElement, ARObject, CollectableElement, Identifiable
|
|
7
|
+
from ....models.general_structure import MultilanguageReferrable, PackageableElement, Referrable
|
|
8
|
+
|
|
9
|
+
class Test_M2_AUTOSARTemplates_CommonStructure_Constants:
|
|
10
|
+
|
|
11
|
+
def test_ValueSpecification(self):
|
|
12
|
+
with pytest.raises(NotImplementedError) as err:
|
|
13
|
+
ValueSpecification()
|
|
14
|
+
assert(str(err.value) == "ValueSpecification is an abstract class.")
|
|
15
|
+
|
|
16
|
+
def test_ConstantSpecification(self):
|
|
17
|
+
document = AUTOSAR.getInstance()
|
|
18
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
19
|
+
spec = ConstantSpecification(ar_root, "constant")
|
|
20
|
+
|
|
21
|
+
assert(isinstance(spec, ARElement))
|
|
22
|
+
assert(isinstance(spec, ARObject))
|
|
23
|
+
assert(isinstance(spec, CollectableElement))
|
|
24
|
+
assert(isinstance(spec, Identifiable))
|
|
25
|
+
assert(isinstance(spec, MultilanguageReferrable))
|
|
26
|
+
assert(isinstance(spec, PackageableElement))
|
|
27
|
+
assert(isinstance(spec, Referrable))
|
|
28
|
+
assert(isinstance(spec, ConstantSpecification))
|
|
29
|
+
|
|
30
|
+
def test_ConstantReference(self):
|
|
31
|
+
ref = ConstantReference()
|
|
32
|
+
|
|
33
|
+
assert(ref.constant_ref == None)
|
|
34
|
+
|
|
35
|
+
assert(isinstance(ref, ARObject))
|
|
36
|
+
assert(isinstance(ref, ValueSpecification))
|
|
37
|
+
assert(isinstance(ref, ConstantReference))
|
|
38
|
+
|
|
39
|
+
class Test_M2_AUTOSARTemplates_CommonStructure_InternalBehavior:
|
|
40
|
+
def test_ExecutableEntity(self):
|
|
41
|
+
document = AUTOSAR.getInstance()
|
|
42
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
43
|
+
with pytest.raises(NotImplementedError) as err:
|
|
44
|
+
ExecutableEntity(ar_root, "ExecutableEntity")
|
|
45
|
+
assert(str(err.value) == "ExecutableEntity is an abstract class.")
|
|
46
|
+
|
|
47
|
+
class Test_M2_AUTOSARTemplates_CommonStructure_ImplementationDataTypes:
|
|
48
|
+
def test_ImplementationDataTypeElement(self):
|
|
49
|
+
document = AUTOSAR.getInstance()
|
|
50
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
51
|
+
data_type = ImplementationDataTypeElement(ar_root, "implementation_data_type")
|
|
52
|
+
|
|
53
|
+
assert(data_type.short_name == "implementation_data_type")
|
|
54
|
+
assert(data_type.array_size == None)
|
|
55
|
+
assert(data_type.is_optional == None)
|
|
56
|
+
|
|
57
|
+
assert(isinstance(data_type, ARObject))
|
|
58
|
+
assert(isinstance(data_type, AbstractImplementationDataTypeElement))
|
|
59
|
+
# assert(isinstance(data_type, AtpClassifier))
|
|
60
|
+
# assert(isinstance(data_type, AtpFeature))
|
|
61
|
+
# assert(isinstance(data_type, AtpStructureElement))
|
|
62
|
+
assert(isinstance(data_type, Identifiable))
|
|
63
|
+
assert(isinstance(data_type, MultilanguageReferrable))
|
|
64
|
+
assert(isinstance(data_type, Referrable))
|
|
65
|
+
assert(isinstance(data_type, ImplementationDataTypeElement))
|
|
66
|
+
|
|
67
|
+
sub_type = data_type.createImplementationDataTypeElement("sub_type")
|
|
68
|
+
assert(sub_type.short_name == "sub_type")
|
|
69
|
+
assert(isinstance(sub_type, ImplementationDataTypeElement))
|
|
70
|
+
|
|
71
|
+
assert(len(data_type.getImplementationDataTypeElements()) == 1)
|
|
72
|
+
sub_type2 = data_type.getImplementationDataTypeElements()[0]
|
|
73
|
+
assert(sub_type == sub_type2)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from ....models.data_dictionary import SwDataDefProps, SwPointerTargetProps
|
|
4
|
+
from ....models.general_structure import ARObject
|
|
5
|
+
|
|
6
|
+
class Test_M2_MSR_DataDictionary_DataDefProperties:
|
|
7
|
+
def test_SwDataDefProps(self):
|
|
8
|
+
props = SwDataDefProps()
|
|
9
|
+
|
|
10
|
+
assert(isinstance(props, ARObject))
|
|
11
|
+
assert(isinstance(props, SwDataDefProps))
|
|
12
|
+
|
|
13
|
+
assert(props.base_type_ref == None)
|
|
14
|
+
assert(props.compu_method_ref == None)
|
|
15
|
+
assert(props.data_constr_ref == None)
|
|
16
|
+
assert(props.implementation_data_type_ref == None)
|
|
17
|
+
assert(props.sw_impl_policy == "")
|
|
18
|
+
assert(props.sw_calibration_access == "")
|
|
19
|
+
assert(props.sw_pointer_target_props == None)
|
|
20
|
+
|
|
21
|
+
def test_SwPointerTargetProps(self):
|
|
22
|
+
props = SwPointerTargetProps()
|
|
23
|
+
|
|
24
|
+
assert(isinstance(props, ARObject))
|
|
25
|
+
assert(isinstance(props, SwPointerTargetProps))
|
|
26
|
+
|
|
27
|
+
assert(props.function_pointer_signature == None)
|
|
28
|
+
assert(props.sw_data_def_props == None)
|
|
29
|
+
assert(props.target_category == "")
|