Skip to content

Commit

Permalink
Make trace-log configurable (#74)
Browse files Browse the repository at this point in the history
* Make trace-log configurable

* Fixed code formating
  • Loading branch information
rquidute authored Feb 26, 2024
1 parent 1104fbe commit 8f9118a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/schemas/test_environment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class DutConfig(BaseModel):
pairing_mode: DutPairingModeEnum
chip_timeout: Optional[str]
chip_use_paa_certs: bool = False
trace_log: bool = True


class TestEnvironmentConfig(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion default_test_environment.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"pairing_mode":"onnetwork",
"setup_code":"20202021",
"discriminator":"3840",
"chip_use_paa_certs":false
"chip_use_paa_certs":false,
"trace_log":true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def generate_command_arguments(

arguments = []
# Increase log level by adding trace log
arguments.append("--trace-to json:log")
if dut_config.trace_log:
arguments.append("--trace-to json:log")
# Retrieve arguments from dut_config
arguments.append(f"--discriminator {dut_config.discriminator}")
arguments.append(f"--passcode {dut_config.setup_code}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,33 @@ async def test_generate_command_arguments_no_test_parameter_informed() -> None:
] == arguments


@pytest.mark.asyncio
async def test_generate_command_arguments_trace_log_false_informed() -> None:
# Mock config
mock_config = default_environment_config.copy(deep=True)

mock_config.test_parameters = None

mock_dut_config = DutConfig(
discriminator="456",
setup_code="8765",
pairing_mode=DutPairingModeEnum.BLE_THREAD,
trace_log=False,
)

mock_config.dut_config = mock_dut_config

arguments = generate_command_arguments(
config=mock_config, omit_commissioning_method=False
)

assert [
"--discriminator 456",
"--passcode 8765",
"--commissioning-method ble-thread",
] == arguments


@pytest.mark.asyncio
async def test_generate_command_arguments_omit_comissioning_method() -> None:
# Mock config
Expand Down

0 comments on commit 8f9118a

Please sign in to comment.