Skip to content

Commit 96fbd3d

Browse files
authored
[Fix] Moved Shared Constants To New File (#277)
* Created shared constants script and added two Enums to the file * Adding MessageKeysEnum as shared, removed original and changing all related imports * Adding TestStateEnum and changing all relevant imports * Exchanging for a app relative import in the models' init file * Updating Copyright's Date Year * Reverting python_tests SHA since it's not ready yet * Updating Matter test scripts SHA
1 parent b902ab5 commit 96fbd3d

46 files changed

Lines changed: 166 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/constants/shared_constants.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# Copyright (c) 2025 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
from enum import Enum
18+
19+
"""
20+
Shared constants across the application.
21+
"""
22+
23+
24+
class TestStateEnum(str, Enum):
25+
__test__ = False # Needed to indicate to PyTest that this is not a "test"
26+
PENDING = "pending"
27+
EXECUTING = "executing"
28+
PENDING_ACTUATION = "pending_actuation" # TODO: Do we need this
29+
PASSED = "passed" # Test Passed with no issued
30+
FAILED = "failed" # Test Failed
31+
ERROR = "error" # Test Error due to tool setup or environment
32+
NOT_APPLICABLE = "not_applicable" # Test is not applicable - e.g. PICS mismatch
33+
CANCELLED = "cancelled"
34+
35+
36+
# Enum Keys for different types of messages currently supported by the tool
37+
class MessageTypeEnum(str, Enum):
38+
PROMPT_REQUEST = "prompt_request"
39+
PROMPT_RESPONSE = "prompt_response"
40+
OPTIONS_REQUEST = "options_request"
41+
MESSAGE_REQUEST = "message_request"
42+
TEST_UPDATE = "test_update"
43+
FILE_UPLOAD_REQUEST = "file_upload_request"
44+
TIME_OUT_NOTIFICATION = "time_out_notification"
45+
TEST_LOG_RECORDS = "test_log_records"
46+
INVALID_MESSAGE = "invalid_message"
47+
STREAM_VERIFICATION_REQUEST = "stream_verification_request"
48+
IMAGE_VERIFICATION_REQUEST = "image_verification_request"
49+
TWO_WAY_TALK_VERIFICATION_REQUEST = "two_way_talk_verification_request"
50+
PUSH_AV_STREAM_VERIFICATION_REQUEST = "push_av_stream_verification_request"
51+
52+
53+
# Enum keys used with messages at the top level
54+
class MessageKeysEnum(str, Enum):
55+
TYPE = "type"
56+
PAYLOAD = "payload"
57+
58+
59+
# Enum for DUT Pairing Modes
60+
class DutPairingModeEnum(str, Enum):
61+
ON_NETWORK = "onnetwork"
62+
BLE_WIFI = "ble-wifi"
63+
BLE_THREAD = "ble-thread"
64+
WIFIPAF_WIFI = "wifipaf-wifi"
65+
NFC_THREAD = "nfc-thread"
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -27,23 +27,6 @@
2727
UDP_SOCKET_INTERFACE = "0.0.0.0"
2828

2929

30-
# Enum Keys for different types of messages currently supported by the tool
31-
class MessageTypeEnum(str, Enum):
32-
PROMPT_REQUEST = "prompt_request"
33-
OPTIONS_REQUEST = "options_request"
34-
MESSAGE_REQUEST = "message_request"
35-
FILE_UPLOAD_REQUEST = "file_upload_request"
36-
PROMPT_RESPONSE = "prompt_response"
37-
TEST_UPDATE = "test_update"
38-
TIME_OUT_NOTIFICATION = "time_out_notification"
39-
TEST_LOG_RECORDS = "test_log_records"
40-
INVALID_MESSAGE = "invalid_message"
41-
STREAM_VERIFICATION_REQUEST = "stream_verification_request"
42-
IMAGE_VERIFICATION_REQUEST = "image_verification_request"
43-
TWO_WAY_TALK_VERIFICATION_REQUEST = "two_way_talk_verification_request"
44-
PUSH_AV_STREAM_VERIFICATION_REQUEST = "push_av_stream_verification_request"
45-
46-
4730
class WebSocketTypeEnum(str, Enum):
4831
MAIN = "main"
4932
VIDEO = "video"
@@ -55,9 +38,3 @@ class WebSocketConnection:
5538
def __init__(self, websocket: WebSocket, socket_type: WebSocketTypeEnum) -> None:
5639
self.websocket = websocket
5740
self.type = socket_type
58-
59-
60-
# Enum keys used with messages at the top level
61-
class MessageKeysEnum(str, Enum):
62-
TYPE = "type"
63-
PAYLOAD = "payload"

app/models/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -13,11 +13,12 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from app.constants.shared_constants import TestStateEnum
17+
1618
from .operator import Operator
1719
from .project import Project
1820
from .test_case_execution import TestCaseExecution
1921
from .test_case_metadata import TestCaseMetadata
20-
from .test_enums import TestStateEnum
2122
from .test_run_config import TestRunConfig
2223
from .test_run_execution import TestRunExecution
2324
from .test_step_execution import TestStepExecution

app/models/test_case_execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222

2323
from app.db.base_class import Base
2424

25-
from .test_enums import TestStateEnum
25+
from . import TestStateEnum
2626

2727
if TYPE_CHECKING:
2828
from .test_case_metadata import TestCaseMetadata # noqa: F401

app/models/test_enums.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

app/models/test_run_execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from app.db.base_class import Base
2626
from app.db.pydantic_data_type import PydanticListType
2727

28-
from .test_enums import TestStateEnum
28+
from . import TestStateEnum
2929
from .test_suite_execution import TestSuiteExecution
3030

3131
if TYPE_CHECKING:

app/models/test_step_execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121

2222
from app.db.base_class import Base
2323

24-
from .test_enums import TestStateEnum
24+
from . import TestStateEnum
2525

2626
if TYPE_CHECKING:
2727
from .test_case_execution import TestCaseExecution # noqa: F401

app/models/test_suite_execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
2323

2424
from app.db.base_class import Base
2525

26+
from . import TestStateEnum
2627
from .test_case_execution import TestCaseExecution
27-
from .test_enums import TestStateEnum
2828

2929
if TYPE_CHECKING:
3030
from .test_run_execution import TestRunExecution # noqa: F401

app/schemas/grouped_test_run_execution_logs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717

1818
from pydantic import BaseModel
1919

20-
from app.models.test_enums import TestStateEnum
20+
from app.models import TestStateEnum
2121
from app.schemas.test_run_log_entry import TestRunLogEntry
2222

2323

app/schemas/test_case_execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Project CHIP Authors
2+
# Copyright (c) 2025 Project CHIP Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818

1919
from pydantic import BaseModel
2020

21-
from app.models.test_enums import TestStateEnum
21+
from app.models import TestStateEnum
2222

2323
from .test_case_metadata import TestCaseMetadata, TestCaseMetadataBase
2424
from .test_step_execution import TestStepExecution, TestStepExecutionToExport

0 commit comments

Comments
 (0)