diff --git a/everest-testing/src/everest/testing/__init__.py b/everest-testing/src/everest/testing/__init__.py index de2aaa4a..dd694a06 100644 --- a/everest-testing/src/everest/testing/__init__.py +++ b/everest-testing/src/everest/testing/__init__.py @@ -1 +1 @@ -__version__="0.4.2" +__version__="0.4.3" diff --git a/everest-testing/src/everest/testing/core_utils/_configuration/everest_environment_setup.py b/everest-testing/src/everest/testing/core_utils/_configuration/everest_environment_setup.py index 1b7698ec..9ed2da69 100644 --- a/everest-testing/src/everest/testing/core_utils/_configuration/everest_environment_setup.py +++ b/everest-testing/src/everest/testing/core_utils/_configuration/everest_environment_setup.py @@ -29,7 +29,6 @@ @dataclass class EverestEnvironmentOCPPConfiguration: - libocpp_path: Path ocpp_version: OCPPVersion central_system_port: int central_system_host: str = "127.0.0.1" @@ -37,7 +36,7 @@ class EverestEnvironmentOCPPConfiguration: template_ocpp_config: Optional[ Path] = None # Path for OCPP config to be used; if not provided, will be determined from everest config device_model_component_config_path: Optional[ - Path] = None # Path of the OCPP device model json schemas. If not set, {libocpp_path} / 'config/v201/component_config' will be used + Path] = None # Path of the OCPP device model json schemas. configuration_strategies: list[OCPPModuleConfigurationStrategy] | None = None @@ -208,9 +207,7 @@ def _setup_libocpp_configuration(self, temporary_paths: _EverestEnvironmentTempo elif self._ocpp_config.ocpp_version == OCPPVersion.ocpp16: source_ocpp_config = self._determine_configured_charge_point_config_path_from_everest_config() elif self._ocpp_config.ocpp_version == OCPPVersion.ocpp201: - source_ocpp_config = self._ocpp_config.device_model_component_config_path \ - if self._ocpp_config.device_model_component_config_path \ - else self._ocpp_config.libocpp_path / 'config/v201/component_config' + source_ocpp_config = self._ocpp_config.device_model_component_config_path return liboccp_configuration_helper.generate_ocpp_config( central_system_port=self._ocpp_config.central_system_port, diff --git a/everest-testing/src/everest/testing/core_utils/controller/everest_test_controller.py b/everest-testing/src/everest/testing/core_utils/controller/everest_test_controller.py index 264c4e97..84710857 100644 --- a/everest-testing/src/everest/testing/core_utils/controller/everest_test_controller.py +++ b/everest-testing/src/everest/testing/core_utils/controller/everest_test_controller.py @@ -55,6 +55,11 @@ def plug_out(self, connector_id=1): f"{self._mqtt_external_prefix}everest_external/nodered/{connector_id}/carsim/cmd/modify_charging_session", "unplug") + def plug_out_iso(self, connector_id=1): + self._mqtt_client.publish( + f"{self._mqtt_external_prefix}everest_external/nodered/{connector_id}/carsim/cmd/modify_charging_session", + "iso_stop_charging;iso_wait_v2g_session_stopped;unplug") + def swipe(self, token, connectors=None): connectors = connectors if connectors is not None else [1] provided_token = { diff --git a/everest-testing/src/everest/testing/core_utils/controller/test_controller_interface.py b/everest-testing/src/everest/testing/core_utils/controller/test_controller_interface.py index 96107327..90e3a230 100644 --- a/everest-testing/src/everest/testing/core_utils/controller/test_controller_interface.py +++ b/everest-testing/src/everest/testing/core_utils/controller/test_controller_interface.py @@ -35,6 +35,12 @@ def plug_in_ac_iso(self, payment_type, connector_id): """ raise NotImplementedError() + def plug_out_iso(self, connector_id): + """ + Plug out of an electric vehicle properly ending the ISO15118 session. + """ + raise NotImplementedError() + def plug_out(self): """ Plug out of an electric vehicle from the chargepoint. diff --git a/everest-testing/src/everest/testing/ocpp_utils/fixtures.py b/everest-testing/src/everest/testing/ocpp_utils/fixtures.py index 1b124c45..3c03f2f4 100644 --- a/everest-testing/src/everest/testing/ocpp_utils/fixtures.py +++ b/everest-testing/src/everest/testing/ocpp_utils/fixtures.py @@ -52,8 +52,8 @@ def ocpp_config(request, central_system: CentralSystem, test_config: OcppTestCon central_system_port=central_system.port, central_system_host="127.0.0.1", ocpp_version=ocpp_version, - libocpp_path=Path(request.config.getoption("--libocpp")), template_ocpp_config=Path(ocpp_config_marker.args[0]) if ocpp_config_marker else None, + device_model_component_config_path=Path(f"{request.config.getoption('--everest-prefix')}/share/everest/modules/OCPP201/component_config"), configuration_strategies=ocpp_configuration_strategies ) @@ -103,9 +103,45 @@ def test_config(): class FtpThread(Thread): + def __init__(self, directory, port, test_config: OcppTestConfiguration, ftp_socket, + group = None, target = None, name = None, args = ..., kwargs = None, *, daemon = None): + super().__init__(group, target, name, args, kwargs, daemon=daemon) + self.directory = directory + self.port = port + self.test_config = test_config + self.ftp_socket = ftp_socket + + def set_directory(self, directory): + self.directory = directory + def set_port(self, port): self.port = port + def set_test_config(self, test_config: OcppTestConfiguration): + self.test_config = test_config + + def set_socket(self, ftp_socket): + self.ftp_socket = ftp_socket + + def stop(self): + self.server.close_all() + + def run(self): + shutil.copyfile(self.test_config.firmware_info.update_file, os.path.join( + self.directory, "firmware_update.pnx")) + shutil.copyfile(self.test_config.firmware_info.update_file_signature, + os.path.join(self.directory, "firmware_update.pnx.base64")) + + authorizer = DummyAuthorizer() + authorizer.add_user(getpass.getuser(), "12345", self.directory, perm="elradfmwMT") + + handler = FTPHandler + handler.authorizer = authorizer + + self.server = servers.FTPServer(self.ftp_socket, handler) + + self.server.serve_forever() + @pytest.fixture def ftp_server(test_config: OcppTestConfiguration): @@ -120,29 +156,14 @@ def ftp_server(test_config: OcppTestConfiguration): ftp_socket.bind(address) port = ftp_socket.getsockname()[1] - def _ftp_server(test_config: OcppTestConfiguration, ftp_socket): - shutil.copyfile(test_config.firmware_info.update_file, os.path.join( - d, "firmware_update.pnx")) - shutil.copyfile(test_config.firmware_info.update_file_signature, - os.path.join(d, "firmware_update.pnx.base64")) - - authorizer = DummyAuthorizer() - authorizer.add_user(getpass.getuser(), "12345", d, perm="elradfmwMT") - - handler = FTPHandler - handler.authorizer = authorizer - - server = servers.FTPServer(ftp_socket, handler) - - server.serve_forever() - - ftp_thread = FtpThread(target=_ftp_server, args=[test_config, ftp_socket]) + ftp_thread = FtpThread(directory=d, port=port, test_config=test_config, ftp_socket=ftp_socket) ftp_thread.daemon = True - ftp_thread.set_port(port) ftp_thread.start() yield ftp_thread + ftp_thread.stop() + shutil.rmtree(d)