Skip to content

Commit

Permalink
Expose OCPP 2.0.1 config with a fixture
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass committed Oct 8, 2024
1 parent 3244bfc commit d1eb811
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self,
self._standalone_module = self._probe_config.module_id
self._additional_everest_config_strategies = everest_config_strategies if everest_config_strategies else []
self._everest_core = None
self._ocpp_configuration = None

def setup_environment(self, tmp_path: Path):

Expand All @@ -128,7 +129,7 @@ def setup_environment(self, tmp_path: Path):
tmp_path=tmp_path)

if self._ocpp_config:
self._setup_libocpp_configuration(
self._ocpp_configuration = self._setup_libocpp_configuration(
temporary_paths=temporary_paths
)

Expand All @@ -140,6 +141,10 @@ def everest_core(self) -> EverestCore:
assert self._everest_core, "Everest Core not initialized; run 'setup_environment' first"
return self._everest_core

@property
def ocpp_config(self):
return self._ocpp_configuration

def _create_temporary_directory_structure(self, tmp_path: Path) -> _EverestEnvironmentTemporaryPaths:
ocpp_config_dir = tmp_path / "ocpp_config"
ocpp_config_dir.mkdir(exist_ok=True)
Expand Down Expand Up @@ -207,7 +212,7 @@ def _setup_libocpp_configuration(self, temporary_paths: _EverestEnvironmentTempo
if self._ocpp_config.device_model_component_config_path \
else self._ocpp_config.libocpp_path / 'config/v201/component_config'

liboccp_configuration_helper.generate_ocpp_config(
return liboccp_configuration_helper.generate_ocpp_config(
central_system_port=self._ocpp_config.central_system_port,
central_system_host=self._ocpp_config.central_system_host,
source_ocpp_config_path=source_ocpp_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def generate_ocpp_config(self,
self._store_config(config, target_ocpp_config_path)
target_ocpp_user_config_file.write_text("{}")

return config

@abstractmethod
def _get_config(self, source_ocpp_config_path: Path):
pass
Expand Down
23 changes: 16 additions & 7 deletions everest-testing/src/everest/testing/core_utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,17 @@ def everest_config_strategies(request) -> list[EverestConfigAdjustmentStrategy]:
return additional_configuration_strategies

@pytest.fixture
def everest_core(request,
def everest_environment(request,
tmp_path,
core_config: EverestEnvironmentCoreConfiguration,
ocpp_config: Optional[EverestEnvironmentOCPPConfiguration],
probe_module_config: Optional[EverestEnvironmentProbeModuleConfiguration],
evse_security_config: Optional[EverestEnvironmentEvseSecurityConfiguration],
persistent_store_config: Optional[EverestEnvironmentPersistentStoreConfiguration],
everest_config_strategies
) -> EverestCore:
"""Fixture that can be used to start and stop everest-core"""

):
standalone_module_marker = request.node.get_closest_marker('standalone_module')


environment_setup = EverestTestEnvironmentSetup(
core_config=core_config,
ocpp_config=ocpp_config,
Expand All @@ -100,11 +97,23 @@ def everest_core(request,
)

environment_setup.setup_environment(tmp_path=tmp_path)
yield environment_setup.everest_core

yield environment_setup

@pytest.fixture
def everest_core(request,
everest_environment
)-> EverestCore:
"""Fixture that can be used to start and stop everest-core"""

yield everest_environment.everest_core

# FIXME (aw): proper life time management, shouldn't the fixure start and stop?
environment_setup.everest_core.stop()
everest_environment.everest_core.stop()

@pytest.fixture
def ocpp_configuration(everest_environment):
yield everest_environment.ocpp_config

@pytest.fixture
def test_controller(request, tmp_path, everest_core) -> EverestTestController:
Expand Down

0 comments on commit d1eb811

Please sign in to comment.