baldertest 0.1.0b10__py3-none-any.whl → 0.1.0b12__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.
Files changed (34) hide show
  1. _balder/_version.py +1 -1
  2. _balder/cnnrelations/__init__.py +7 -0
  3. _balder/cnnrelations/and_connection_relation.py +149 -0
  4. _balder/cnnrelations/base_connection_relation.py +270 -0
  5. _balder/cnnrelations/or_connection_relation.py +65 -0
  6. _balder/collector.py +10 -16
  7. _balder/connection.py +400 -881
  8. _balder/connection_metadata.py +255 -0
  9. _balder/controllers/device_controller.py +37 -16
  10. _balder/controllers/feature_controller.py +63 -99
  11. _balder/controllers/normal_scenario_setup_controller.py +5 -5
  12. _balder/controllers/scenario_controller.py +6 -6
  13. _balder/controllers/setup_controller.py +2 -3
  14. _balder/decorator_connect.py +12 -10
  15. _balder/decorator_for_vdevice.py +17 -25
  16. _balder/decorator_gateway.py +3 -3
  17. _balder/executor/testcase_executor.py +0 -1
  18. _balder/executor/variation_executor.py +212 -199
  19. _balder/feature.py +1 -1
  20. _balder/feature_replacement_mapping.py +69 -0
  21. _balder/feature_vdevice_mapping.py +88 -0
  22. _balder/fixture_manager.py +10 -9
  23. _balder/objects/connections/osi_3_network.py +2 -2
  24. _balder/objects/connections/osi_4_transport.py +2 -2
  25. _balder/routing_path.py +27 -31
  26. _balder/solver.py +1 -1
  27. _balder/testresult.py +1 -1
  28. _balder/utils.py +27 -1
  29. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/METADATA +2 -2
  30. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/RECORD +34 -27
  31. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/WHEEL +1 -1
  32. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/LICENSE +0 -0
  33. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/entry_points.txt +0 -0
  34. {baldertest-0.1.0b10.dist-info → baldertest-0.1.0b12.dist-info}/top_level.txt +0 -0
@@ -7,6 +7,7 @@ from abc import ABC, abstractmethod
7
7
  from _balder.setup import Setup
8
8
  from _balder.device import Device
9
9
  from _balder.scenario import Scenario
10
+ from _balder.connection_metadata import ConnectionMetadata
10
11
  from _balder.controllers.controller import Controller
11
12
  from _balder.controllers.device_controller import DeviceController
12
13
  from _balder.controllers.vdevice_controller import VDeviceController
@@ -374,11 +375,10 @@ class NormalScenarioSetupController(Controller, ABC):
374
375
  all_devices[all_devices_as_strings.index(cur_parent_cnn.from_device.__name__)]
375
376
  related_to_device = all_devices[all_devices_as_strings.index(cur_parent_cnn.to_device.__name__)]
376
377
  new_cnn = cur_parent_cnn.clone()
377
- new_cnn.set_metadata_for_all_subitems(None)
378
- new_cnn.set_metadata_for_all_subitems(
379
- {"from_device": related_from_device, "to_device": related_to_device,
380
- "from_device_node_name": cur_parent_cnn.from_node_name,
381
- "to_device_node_name": cur_parent_cnn.to_node_name})
378
+ new_cnn.set_metadata_for_all_subitems(ConnectionMetadata(
379
+ from_device=related_from_device, from_device_node_name=cur_parent_cnn.from_node_name,
380
+ to_device=related_to_device, to_device_node_name=cur_parent_cnn.to_node_name)
381
+ )
382
382
  all_relevant_cnns.append(new_cnn)
383
383
 
384
384
  # throw warning (but only if this scenario/setup has minimum one of the parent classes has inner
@@ -4,6 +4,7 @@ from typing import Type, Dict, List, Tuple, Union, Callable, Iterable, Any
4
4
  import logging
5
5
  import inspect
6
6
  from collections import OrderedDict
7
+ from _balder.cnnrelations import OrConnectionRelation
7
8
  from _balder.device import Device
8
9
  from _balder.scenario import Scenario
9
10
  from _balder.connection import Connection
@@ -215,15 +216,15 @@ class ScenarioController(NormalScenarioSetupController):
215
216
 
216
217
  # now check if one or more single of the classbased connection are CONTAINED IN the possible
217
218
  # parallel connection (only if there exists more than one parallel)
218
- feature_cnn = Connection.based_on(*FeatureController.get_for(
219
- cur_feature.__class__).get_abs_class_based_for_vdevice()[mapped_vdevice])
219
+ feature_cnn = FeatureController.get_for(
220
+ cur_feature.__class__).get_abs_class_based_for_vdevice()[mapped_vdevice]
220
221
 
221
222
  # search node names that is the relevant connection
222
223
  relevant_cnns: List[Connection] = []
223
224
  mapped_device_abs_cnns = DeviceController.get_for(mapped_device).get_all_absolute_connections()
224
225
  for _, all_connections in mapped_device_abs_cnns.items():
225
226
  relevant_cnns += [cur_cnn for cur_cnn in all_connections
226
- if cur_cnn.has_connection_from_to(cur_from_device, mapped_device)]
227
+ if cur_cnn.has_connection_from_to(cur_from_device, end_device=mapped_device)]
227
228
 
228
229
  if len(relevant_cnns) <= 1:
229
230
  # ignore if there are not more than one relevant connection
@@ -338,10 +339,9 @@ class ScenarioController(NormalScenarioSetupController):
338
339
  continue
339
340
 
340
341
  # now try to reduce the scenario connections according to the requirements of the feature class
341
- cur_feature_class_based_for_vdevice = \
342
+ cur_feature_cnn = \
342
343
  FeatureController.get_for(
343
344
  cur_feature.__class__).get_abs_class_based_for_vdevice()[mapped_vdevice]
344
- cur_feature_cnn = Connection.based_on(*cur_feature_class_based_for_vdevice)
345
345
 
346
346
  device_cnn_singles = get_single_cnns_between_device_for_feature(
347
347
  from_device=cur_from_device, to_device=mapped_device, relevant_feature_cnn=cur_feature_cnn)
@@ -395,7 +395,7 @@ class ScenarioController(NormalScenarioSetupController):
395
395
  cur_from_device_controller = DeviceController.get_for(cur_from_device)
396
396
  cur_to_device_controller = DeviceController.get_for(cur_to_device)
397
397
 
398
- new_cnn = Connection.based_on(*cur_single_cnns)
398
+ new_cnn = Connection.based_on(OrConnectionRelation(*cur_single_cnns))
399
399
  new_cnn.set_metadata_for_all_subitems(cur_single_cnns[0].metadata)
400
400
  if cur_from_device == cur_single_cnns[0].from_device:
401
401
  cur_from_device_controller.add_new_absolute_connection(new_cnn)
@@ -3,7 +3,6 @@ from typing import Type, Dict, Union, TYPE_CHECKING
3
3
 
4
4
  import logging
5
5
  from _balder.setup import Setup
6
- from _balder.connection import Connection
7
6
  from _balder.exceptions import IllegalVDeviceMappingError, MultiInheritanceError
8
7
  from _balder.controllers.feature_controller import FeatureController
9
8
  from _balder.controllers.device_controller import DeviceController
@@ -113,12 +112,12 @@ class SetupController(NormalScenarioSetupController):
113
112
  continue
114
113
 
115
114
  # there exists a class based requirement for this vDevice
116
- class_based_cnn = Connection.based_on(*feature_class_based_for_vdevice[mapped_vdevice])
115
+ class_based_cnn = feature_class_based_for_vdevice[mapped_vdevice]
117
116
  # search relevant connection
118
117
  cur_device_controller = DeviceController.get_for(cur_device)
119
118
  for _, cur_cnn_list in cur_device_controller.get_all_absolute_connections().items():
120
119
  for cur_cnn in cur_cnn_list:
121
- if not cur_cnn.has_connection_from_to(cur_device, mapped_device):
120
+ if not cur_cnn.has_connection_from_to(cur_device, end_device=mapped_device):
122
121
  # this connection can be ignored, because it is no connection between the current device
123
122
  # and the mapped device
124
123
  continue
@@ -5,10 +5,15 @@ import re
5
5
  from _balder.device import Device
6
6
  from _balder.connection import Connection
7
7
  from _balder.controllers import DeviceController
8
+ from _balder.cnnrelations import AndConnectionRelation, OrConnectionRelation
8
9
 
9
10
 
10
- def connect(with_device: Union[Type[Device], str], over_connection: Union[Type[Connection], Connection],
11
- self_node_name: str = None, dest_node_name: str = None):
11
+ def connect(
12
+ with_device: Union[Type[Device], str],
13
+ over_connection: Union[Connection, Type[Connection], AndConnectionRelation, OrConnectionRelation],
14
+ self_node_name: str = None,
15
+ dest_node_name: str = None
16
+ ):
12
17
  """
13
18
  This decorator connects two devices with each other. It can be used for scenarios as well as setup devices.
14
19
 
@@ -27,11 +32,6 @@ def connect(with_device: Union[Type[Device], str], over_connection: Union[Type[C
27
32
  if not isinstance(with_device, str) and not issubclass(with_device, Device):
28
33
  raise ValueError("the value of `with_device` must be a `Device` (or a subclass thereof) or the device name "
29
34
  "as a string")
30
- if isinstance(over_connection, tuple):
31
- # doesn't make sense, because we can describe what's needed in one scenario with several `@connect` decorations
32
- # anyway. We are describing a setup, therefore an AND link makes no sense here either
33
- raise TypeError("an AND link (signaled via the tuple) of the connection is not possible here - for further "
34
- "separate connections use the `@connect` decorator again")
35
35
  if isinstance(over_connection, type):
36
36
  if not issubclass(over_connection, Connection):
37
37
  raise TypeError("the type of `over_connection` must be a `Connection` (or a subclass of it)")
@@ -91,11 +91,13 @@ def connect(with_device: Union[Type[Device], str], over_connection: Union[Type[C
91
91
  # in another `@connect()` decorator (and also remove possible metadata from the new clone)
92
92
  cur_cnn_instance = over_connection.clone()
93
93
  cur_cnn_instance.set_metadata_for_all_subitems(None)
94
- elif issubclass(over_connection, Connection):
94
+ elif isinstance(over_connection, type) and issubclass(over_connection, Connection):
95
95
  # not instantiated -> instantiate it
96
96
  cur_cnn_instance = over_connection()
97
- cur_cnn_instance.set_devices(from_device=decorated_cls, to_device=with_device)
98
- cur_cnn_instance.update_node_names(from_device_node_name=self_node_name, to_device_node_name=dest_node_name)
97
+ elif isinstance(over_connection, (AndConnectionRelation, OrConnectionRelation)):
98
+ over_connection = Connection.based_on(over_connection)
99
+ cur_cnn_instance.metadata.set_from(from_device=decorated_cls, from_device_node_name=self_node_name)
100
+ cur_cnn_instance.metadata.set_to(to_device=with_device, to_device_node_name=dest_node_name)
99
101
 
100
102
  decorated_cls_device_controller.add_new_raw_connection(cur_cnn_instance)
101
103
  return decorated_cls
@@ -1,7 +1,8 @@
1
1
  from __future__ import annotations
2
- from typing import List, Union, Type, Tuple
2
+ from typing import Union, Type
3
3
 
4
4
  import inspect
5
+ from _balder.cnnrelations import AndConnectionRelation, OrConnectionRelation
5
6
  from _balder.collector import Collector
6
7
  from _balder.feature import Feature
7
8
  from _balder.vdevice import VDevice
@@ -13,9 +14,9 @@ from _balder.exceptions import DuplicateForVDeviceError, UnknownVDeviceException
13
14
  def for_vdevice(
14
15
  vdevice: Union[str, Type[VDevice]],
15
16
  with_connections: Union[
16
- Type[Connection], Connection, Tuple[Union[Type[Connection], Connection]],
17
- List[Union[Type[Connection], Connection, Tuple[Union[Type[Connection], Connection]]]]] = Connection(),
18
- ):
17
+ Type[Connection], Connection, AndConnectionRelation, OrConnectionRelation
18
+ ] = Connection(),
19
+ ):
19
20
  """
20
21
  With the `@for_vdevice` you can limit the decorated object for a special allowed connection tree for every existing
21
22
  vDevice. This decorator can be used to decorate whole :class:`Feature` classes just like single methods of a
@@ -37,26 +38,18 @@ def for_vdevice(
37
38
 
38
39
  :param with_connections: the assigned connection trees for this class/method (default: a universal connection)
39
40
  """
40
- idx = 0
41
- if not isinstance(with_connections, list):
42
- with_connections = [with_connections]
43
- for cur_conn in with_connections:
44
- if isinstance(cur_conn, type):
45
- if not issubclass(cur_conn, Connection):
46
- raise ValueError(f"the given element type for the element on position `{idx}` has to be a subclass of "
47
- f"`{Connection.__name__}` or a element of it")
48
- elif isinstance(cur_conn, tuple):
49
- tuple_idx = 0
50
- for cur_tuple_elem in cur_conn:
51
- if not isinstance(cur_tuple_elem, Connection) and not issubclass(cur_tuple_elem, Connection):
52
- raise ValueError(f"the given tuple element `{tuple_idx}` that is given on position `{idx}` "
53
- f"has to be a subclass of `{Connection.__name__}`")
54
- tuple_idx += 1
55
- elif not isinstance(cur_conn, Connection):
56
- raise ValueError(f"the given type on position `{idx}` has to be a subclass of `{Connection.__name__}` or "
57
- f"a element of it")
58
-
59
- idx += 1
41
+ if isinstance(with_connections, Connection):
42
+ # do nothing
43
+ pass
44
+ elif isinstance(with_connections, (AndConnectionRelation, OrConnectionRelation)):
45
+ # use container connection
46
+ with_connections = Connection.based_on(with_connections)
47
+ elif isinstance(with_connections, type) and issubclass(with_connections, Connection):
48
+ # instantiate it
49
+ with_connections = with_connections()
50
+ else:
51
+ raise TypeError(f"the given element ``with_connection`` needs to be from type `AndConnectionRelation`, "
52
+ f"`OrConnectionRelation` or `Connection` - `{type(with_connections)}` is not allowed")
60
53
 
61
54
  # note: if `args` is an empty list - no special sub-connection-tree bindings
62
55
 
@@ -105,7 +98,6 @@ def for_vdevice(
105
98
 
106
99
  vdevice = relevant_vdevices[0]
107
100
  cls_for_vdevice = fn_feature_controller.get_class_based_for_vdevice()
108
- cls_for_vdevice = {} if cls_for_vdevice is None else cls_for_vdevice
109
101
  if vdevice in cls_for_vdevice.keys():
110
102
  raise DuplicateForVDeviceError(
111
103
  f'there already exists a decorator for the vDevice `{vdevice}` in the Feature class '
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from _balder.controllers.device_controller import DeviceController
3
4
  from _balder.device import Device
4
5
  from _balder.node_gateway import NodeGateway
5
6
 
@@ -25,10 +26,9 @@ def gateway(from_node: str, to_node: str, bidirectional: bool = True):
25
26
  raise TypeError(
26
27
  f"The decorator `gateway` may only be used for `Device` objects. This is not possible for the applied "
27
28
  f"class `{cls.__name__}`.")
29
+ decorated_cls_device_controller = DeviceController.get_for(cls)
28
30
 
29
- if not hasattr(cls, '_gateways'):
30
- cls._gateways = []
31
31
  new_gateway = NodeGateway(cls, from_node, to_node, bidirectional)
32
- cls._gateways.append(new_gateway)
32
+ decorated_cls_device_controller.add_new_raw_gateway(new_gateway)
33
33
  return cls
34
34
  return decorator
@@ -12,7 +12,6 @@ from _balder.testresult import ResultState, TestcaseResult
12
12
  from _balder.utils import inspect_method
13
13
 
14
14
  if TYPE_CHECKING:
15
- from _balder.executor.unresolved_parametrized_testcase_executor import UnresolvedParametrizedTestcaseExecutor
16
15
  from _balder.executor.variation_executor import VariationExecutor
17
16
  from _balder.fixture_manager import FixtureManager
18
17
  from _balder.scenario import Scenario