Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Fix server_type handling #144

Merged
merged 1 commit into from
Oct 20, 2023
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
2 changes: 1 addition & 1 deletion dbc2val/dbcfeeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def _get_command_line_args_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--server-type",
help="The type of KUKSA.val server to write/read VSS signal to/from",
choices=[server_type.name for server_type in ServerType]
choices=[server_type.value for server_type in ServerType]
)
parser.add_argument(
"--lax-dbc-parsing",
Expand Down
12 changes: 12 additions & 0 deletions dbc2val/test/test_arguments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
########################################################################
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License 2.0 which is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
########################################################################
46 changes: 46 additions & 0 deletions dbc2val/test/test_arguments/test_arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
########################################################################
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License 2.0 which is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
########################################################################

import pytest
import os


@pytest.fixture
def change_test_dir(request, monkeypatch):
# To make sure we run from test directory
monkeypatch.chdir(request.fspath.dirname)


@pytest.mark.parametrize("requested_server, ok_expected", [
('kuksa_databroker', True),
('kuksa_val_server', True),
('KUKSA_DATABROKER', False),
('KUKSA_VAL_SERVER', False)])
def test_server_type(requested_server, ok_expected, change_test_dir):
test_str = "../../dbcfeeder.py --server-type " + requested_server + " --help > out.txt 2>&1"
result = os.system(test_str)
assert os.WIFEXITED(result)
if ok_expected:
assert os.WEXITSTATUS(result) == 0
# Check that we get normal help
test_str = r'grep "\-\-server-type {kuksa_val_server,kuksa_databroker}" out.txt > /dev/null'
else:
assert os.WEXITSTATUS(result) != 0
# Check that we get error
test_str = r'grep "(choose from ' + r"'kuksa_val_server', 'kuksa_databroker')" + r'" out.txt > /dev/null'

result = os.system(test_str)
os.system("cat out.txt")
os.system("rm -f out.json out.txt")
assert os.WIFEXITED(result)
assert os.WEXITSTATUS(result) == 0