How to use the ocpp.messages.CallResult function in ocpp

To help you get started, we’ve selected a few ocpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mobilityhouse / ocpp / tests / test_messages.py View on Github external
def test_call_result_representation():
    call = CallResult(
        unique_id="1", action=Action.Authorize, payload={"status": "Accepted"}
    )

    assert str(call) == \
        ""
github mobilityhouse / ocpp / tests / test_messages.py View on Github external
def test_validate_payload_with_invalid_payload():
    """
    Test if validate_payload raises ValidationError when validation of
    payload failes.
    """
    message = CallResult(
        unique_id="1234",
        action="Heartbeat",
        payload={'invalid_key': True},
    )

    with pytest.raises(ValidationError):
        validate_payload(message, ocpp_version="1.6")
github mobilityhouse / ocpp / tests / test_messages.py View on Github external
def test_validate_payload_with_non_existing_schema():
    """
    Test if correct exception is raised when a validation schema cannot be
    found.
    """
    message = CallResult(
        unique_id="1234",
        action="MagicSpell",
        payload={'invalid_key': True},
    )

    with pytest.raises(ValidationError):
        validate_payload(message, ocpp_version="1.6")
github mobilityhouse / ocpp / tests / test_messages.py View on Github external
def test_validate_payload_with_valid_payload(ocpp_version):
    """
    Test if validate_payload doesn't return any exceptions when it's
    validating a valid payload.
    """
    message = CallResult(
        unique_id="1234",
        action="Heartbeat",
        payload={'currentTime': datetime.now().isoformat()}
    )

    validate_payload(message, ocpp_version=ocpp_version)
github mobilityhouse / ocpp / ocpp / messages.py View on Github external
def create_call_result(self, payload):
        call_result = CallResult(self.unique_id, payload)
        call_result.action = self.action
        return call_result