Skip to content

Commit

Permalink
Fixing lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
gladystonfranca committed Sep 18, 2024
1 parent 98446af commit 66c5a55
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 80 deletions.
15 changes: 10 additions & 5 deletions app/api/api_v1/endpoints/test_run_executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
selected_tests_from_execution,
)
from app.version import version_information
from test_collections.matter.sdk_tests.support.performance_tests.utils import (
create_summary_report,
)
from test_collections.matter.test_environment_config import TestEnvironmentConfigMatter
from test_collections.matter.sdk_tests.support.performance_tests.utils import create_summary_report

router = APIRouter()


@router.get("/", response_model=List[schemas.TestRunExecutionWithStats])
def read_test_run_executions(
db: Session = Depends(get_db),
Expand Down Expand Up @@ -483,8 +486,10 @@ def import_test_run_execution(
detail=str(error),
)


date_pattern_out_file = "%Y_%m_%d_%H_%M_%S"


@router.post("/{id}/performance_summary")
def generate_summary_log(
*,
Expand Down Expand Up @@ -538,9 +543,9 @@ def generate_summary_log(
else:
timestamp = datetime.now().strftime(date_pattern_out_file)


tc_name, execution_time_folder = create_summary_report(timestamp, log_lines_list, commissioning_method)

tc_name, execution_time_folder = create_summary_report(
timestamp, log_lines_list, commissioning_method
)

target_dir = f"{HOST_OUT_FOLDER}/{execution_time_folder}/{tc_name}"
url_report = f"{matter_qa_url}/home/displayLogFolder?dir_path={target_dir}"
Expand All @@ -553,4 +558,4 @@ def generate_summary_log(
return JSONResponse(
jsonable_encoder(summary_report),
**options,
)
)
2 changes: 1 addition & 1 deletion app/test_engine/models/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, test_case_execution: TestCaseExecution):
self.create_test_steps()
self.__state = TestStateEnum.PENDING
self.errors: List[str] = []
self.analytics: dict[str:str] = {} # Move to dictionary
self.analytics: dict[str:str] = {} # Move to dictionary

Check failure on line 65 in app/test_engine/models/test_case.py

View workflow job for this annotation

GitHub Actions / Mypy

app/test_engine/models/test_case.py#L65

"dict" expects 2 type arguments, but 1 given [type-arg]

Check failure on line 65 in app/test_engine/models/test_case.py

View workflow job for this annotation

GitHub Actions / Mypy

app/test_engine/models/test_case.py#L65

Invalid type comment or annotation [valid-type]

# Make pics a class method as they are mostly needed at class level.
@classmethod
Expand Down
24 changes: 16 additions & 8 deletions app/test_engine/test_script_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ def ___pending_test_cases_for_test_suite(
)
test_cases = []

if (test_suite.public_id == 'Performance Test Suite'):
if test_suite.public_id == "Performance Test Suite":
test_cases = self.__pending_test_cases_for_iterations(
test_case=test_case_declaration, iterations=1
)

test_cases[0].test_case_metadata.count = iterations
else:
test_cases = self.__pending_test_cases_for_iterations(
test_cases = self.__pending_test_cases_for_iterations(
test_case=test_case_declaration, iterations=iterations
)

Expand Down Expand Up @@ -285,20 +285,26 @@ def __load_test_suite_test_cases(
) -> None:
test_suite.test_cases = []

if (test_suite_declaration.public_id == 'Performance Test Suite'):
if test_suite_declaration.public_id == "Performance Test Suite":
test_case_declaration = self.__test_case_declaration(
test_case_executions[0].public_id,
test_suite_declaration=test_suite_declaration,
)
TestCaseClass = test_case_declaration.class_ref
test_case = TestCaseClass(test_case_execution=test_case_executions[0])

additional_step_count = int(test_case_executions[0].test_case_metadata.count) - 1
additional_step_count = (
int(test_case_executions[0].test_case_metadata.count) - 1
)

for index in range(2,additional_step_count+2):
test_case.test_steps.insert(index, TestStep(f"Loop Commissioning ... {index}"))
for index in range(2, additional_step_count + 2):
test_case.test_steps.insert(
index, TestStep(f"Loop Commissioning ... {index}")
)

self.create_pending_teststeps_execution(db, test_case, test_case_executions[0])
self.create_pending_teststeps_execution(
db, test_case, test_case_executions[0]
)
test_suite.test_cases.append(test_case)
else:
for test_case_execution in test_case_executions:
Expand All @@ -309,7 +315,9 @@ def __load_test_suite_test_cases(
)
TestCaseClass = test_case_declaration.class_ref
test_case = TestCaseClass(test_case_execution=test_case_execution)
self.create_pending_teststeps_execution(db, test_case, test_case_execution)
self.create_pending_teststeps_execution(
db, test_case, test_case_execution
)
test_suite.test_cases.append(test_case)

def create_pending_teststeps_execution(
Expand Down
3 changes: 1 addition & 2 deletions app/user_prompt_support/uploaded_file_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class UploadFile(Protocol):
filename: Optional[str]

@property
def content_type(self) -> Optional[str]:
...
def content_type(self) -> Optional[str]: ...


@runtime_checkable
Expand Down
4 changes: 1 addition & 3 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
class InvalidProgramConfigurationError(Exception):
"""'Exception raised when the program configuration is invalid"""

pass


def send_email(
email_to: str,
Expand Down Expand Up @@ -168,7 +166,7 @@ def selected_tests_from_execution(run: TestRunExecution) -> TestSelection:
for suite in run.test_suite_executions:
selected_tests.setdefault(suite.collection_id, {})
selected_tests[suite.collection_id].setdefault(suite.public_id, {})
suite_dict = selected_tests[suite.collection_id][suite.public_id]
selected_tests[suite.collection_id][suite.public_id]
for case in suite.test_case_executions:
if (
case.public_id
Expand Down
4 changes: 1 addition & 3 deletions test_collections/matter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
# Verify if this execution comes from python_tests_validator.
if not os.getenv("DRY_RUN"):
from .python_tests import onboarding_payload_collection
from .sdk_tests.support.performance_tests import sdk_performance_collection
from .sdk_tests.support.python_testing import (
custom_python_collection,
sdk_mandatory_python_collection,
sdk_python_collection,
)
from .sdk_tests.support.yaml_tests import custom_collection, sdk_collection
from .sdk_tests.support.performance_tests import (
sdk_performance_collection,
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@

# Test engine will auto load TestCollectionDeclarations declared inside the package
# initializer
sdk_performance_collection: TestCollectionDeclaration = sdk_performance_test_collection()
sdk_performance_collection: TestCollectionDeclaration = (
sdk_performance_test_collection()
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from matter_yamltests.hooks import TestRunnerHooks
from pydantic import BaseModel
from app.test_engine.logger import test_engine_logger as logger


class SDKPythonTestResultEnum(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from multiprocessing.managers import BaseManager
from pathlib import Path
from socket import SocketIO
from typing import Any, Generator, Optional, Type, TypeVar, cast
from typing import Any, Optional, Type, TypeVar

from app.models import TestCaseExecution
from app.test_engine.logger import PYTHON_TEST_LEVEL
Expand All @@ -47,7 +47,6 @@
RUNNER_CLASS_PATH,
commission_device,
generate_command_arguments,
handle_logs,
)


Expand Down Expand Up @@ -213,9 +212,11 @@ def __class_factory(cls, test: PythonTest, python_test_version: str) -> Type[T]:
"python_test": test,
"python_test_version": python_test_version,
"metadata": {
"public_id": test.name
if python_test_version != CUSTOM_TEST_IDENTIFIER
else test.name + "-" + CUSTOM_TEST_IDENTIFIER,
"public_id": (
test.name
if python_test_version != CUSTOM_TEST_IDENTIFIER
else test.name + "-" + CUSTOM_TEST_IDENTIFIER
),
"version": "0.0.1",
"title": title,
"description": test.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def __class_factory(cls, name: str, python_test_version: str) -> Type[T]:
"name": name,
"python_test_version": python_test_version,
"metadata": {
"public_id": name
if python_test_version != "custom"
else name + "-custom",
"public_id": (
name if python_test_version != "custom" else name + "-custom"
),
"version": "0.0.1",
"title": name,
"description": name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import time
import logging
import subprocess
import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.clusters.Types import NullValue
from chip.interaction_model import InteractionModelError, Status
from matter_testing_support import (
MatterBaseTest,
TestStep,
Expand Down Expand Up @@ -109,9 +106,8 @@ async def test_TC_COMMISSIONING_1_0(self):
except Exception:
pass

for i in range(1, interactions+1):
self.additional_steps.insert(i,TestStep(i, f"Loop Commissioning ... {i}"))

for i in range(1, interactions + 1):
self.additional_steps.insert(i, TestStep(i, f"Loop Commissioning ... {i}"))

for i in range(1, interactions + 1):
self.step(i)
Expand All @@ -120,24 +116,30 @@ async def test_TC_COMMISSIONING_1_0(self):
f"|============== Begin Commission {i} =========================|"
)

logging.info("|============== Accessory LifeCycle =========================|")
logging.info(
"|============== Accessory LifeCycle =========================|"
)

logging.info("INFO Internal Control reset simulated app ")
accessory_manager.clean()

logging.info("INFO Internal Control start simulated app ")
accessory_manager.start()

logging.info("|============== Commissioning Steps =========================|")
logging.info(
"|============== Commissioning Steps =========================|"
)

await self.commission_and_base_checks()

time.sleep(0.5)
logging.info("|============== Accessory LifeCycle =========================|")
logging.info(
"|============== Accessory LifeCycle =========================|"
)
logging.info("INFO Internal Control stop simulated app")
accessory_manager.stop()
accessory_manager.clean()

def clean_chip_tool_kvs(self):

Check failure on line 143 in test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/TC_COMMISSIONING_1_0.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/TC_COMMISSIONING_1_0.py#L143

Function is missing a return type annotation [no-untyped-def]
try:
subprocess.check_call("rm -f /root/admin_storage.json", shell=True)
Expand All @@ -148,4 +150,3 @@ def clean_chip_tool_kvs(self):

if __name__ == "__main__":
default_matter_test_main()

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from abc import ABC, abstractmethod


# This interface must be implemented to provide basic access to accessory functionality.
class AccessoryInterface(ABC):
@abstractmethod
Expand All @@ -30,7 +31,8 @@ def stop(self):
@abstractmethod
def clean(self):

Check failure on line 32 in test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py#L32

Function is missing a return type annotation [no-untyped-def]
pass



from .simulated_accessory import SimulatedAccessory

Check failure on line 36 in test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py

View workflow job for this annotation

GitHub Actions / Flake8

test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py#L36

Module level import not at top of file (E402)


Expand All @@ -47,5 +49,3 @@ def stop(self):

def clean(self):

Check failure on line 50 in test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/accessory_manager.py#L50

Function is missing a return type annotation [no-untyped-def]
self.accessory.clean()


Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import subprocess
from .accessory_manager import AccessoryInterface


class SimulatedAccessory(AccessoryInterface):

def __init__(self):

Check failure on line 24 in test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/simulated_accessory.py

View workflow job for this annotation

GitHub Actions / Mypy

test_collections/matter/sdk_tests/support/performance_tests/scripts/sdk/simulated_accessory.py#L24

Function is missing a return type annotation [no-untyped-def]
Expand Down Expand Up @@ -59,4 +60,4 @@ def clean(self):
except subprocess.CalledProcessError as e:
print(
f"Error while trying to remove possible simulator ghost instances: {e}"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# limitations under the License.
#
from pathlib import Path
from typing import Optional

from ..models.sdk_test_folder import SDKTestFolder
from ..paths import SDK_CHECKOUT_PATH
from .models.python_test_models import PythonTestType
from .models.python_test_parser import parse_python_script
from .models.test_declarations import (
Expand All @@ -32,13 +30,12 @@
# `./models/rpc_client/`.
#
# This is a temporary solution since those tests should come from SDK.
#
#
###

STRESS_TEST_PATH = Path(__file__).resolve().parent / "scripts/sdk/"
STRESS_TEST_FOLDER = SDKTestFolder(
path=STRESS_TEST_PATH, filename_pattern="TC_*"
)
STRESS_TEST_FOLDER = SDKTestFolder(path=STRESS_TEST_PATH, filename_pattern="TC_*")


def _init_test_suites(
python_test_version: str,
Expand Down
Loading

0 comments on commit 66c5a55

Please sign in to comment.