certification-tool icon indicating copy to clipboard operation
certification-tool copied to clipboard

Update TestSelection to use Pydantic

Open raju-apple opened this issue 1 year ago • 1 comments

From chip-certification-tool-backend created by antonio-amjr: CHIP-Specifications/chip-certification-tool-backend#585

Feature description

Update the TestSelection nested dictionary structure we have today to use Pydantic. That way we may benefit from the advanced features like validations or nested data model.

As an example, we could have:

class SelectedTestCase(BaseModel):
  public_id: str
  iterations: int = 1

class SelectedTestSuite(BaseModel):
  public_id: str
  test_cases: list [SelectedTestCase] = []

class SelectedCollection(BaseModel):
  collection_name: str
  test_suites: list[SelectedTestSuite] = []

class TestSelection(BaseModel):
  collections: list[SelectedCollection] = []

Use Cases

As a nested data model, the data for TestSelection would be something like:

{
    "collections": [
        {
            "name": "Collection Name",
            "test_suites": [
                {
                    "public_id": "Test Suite ID",
                    "test_cases": [
                        {"public_id": "TestCase1", "iterations": 1},
                        {"public_id": "TestCase2", "iterations": 2},
                    ],
                },
            ],
        }
    ]
}

Test Cases

Many already existing unit tests and code logic would have the change to accommodate this new data models.

Additional Information

No response

raju-apple avatar Oct 19 '23 19:10 raju-apple

This is not done. This was discussed in the PR above but it was postpone until a proper moment come. It's interesting to track this also. I'll add to the task list.

For now, I'm reopening it.

raju-apple avatar Oct 19 '23 19:10 raju-apple

Deprioritized.

fabiowmm avatar Oct 10 '24 18:10 fabiowmm