Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TransportScheme): Add http transport used in opennetzteil and use StrEnum #564

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/gallia/transports/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
# SPDX-License-Identifier: Apache-2.0

import sys
from enum import Enum, unique
from enum import StrEnum, unique

TCP = "tcp"
TCP_LINES = "tcp-lines"
HTTP = "http"
DOIP = "doip"


if sys.platform.startswith("linux"):

@unique
class TransportScheme(str, Enum):
class TransportScheme(StrEnum):
TCP = TCP
TCP_LINES = TCP_LINES
HTTP = HTTP
DOIP = DOIP
UNIX = "unix"
UNIX_LINES = "unix-lines"
Expand All @@ -27,9 +29,10 @@ class TransportScheme(str, Enum):
if sys.platform == "win32":

@unique
class TransportScheme(str, Enum):
class TransportScheme(StrEnum):
TCP = TCP
TCP_LINES = TCP_LINES
HTTP = HTTP
DOIP = DOIP

FLEXRAY_RAW = "fr-raw"
Expand Down
5 changes: 3 additions & 2 deletions tests/test_target_uris.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from gallia.transports import TargetURI
from gallia.transports.doip import DoIPConfig
from gallia.transports.isotp import ISOTPConfig
from gallia.transports.schemes import TransportScheme
from pydantic import ValidationError

uris = [
Expand Down Expand Up @@ -42,9 +43,9 @@
def _test_uri(uri: str) -> None:
parsed_uri = TargetURI(uri)
match parsed_uri.scheme:
case "doip":
case TransportScheme.DOIP:
DoIPConfig(**parsed_uri.qs_flat)
case "isotp":
case TransportScheme.ISOTP:
ISOTPConfig(**parsed_uri.qs_flat)
case _:
raise ValueError(f"uncovered scheme: {parsed_uri.scheme}")
Expand Down
Loading