From d4bd5d68fc34d4176a176cf9109c4f1b7a67ede8 Mon Sep 17 00:00:00 2001 From: Mark Moes Date: Thu, 26 Oct 2023 16:34:07 +0200 Subject: [PATCH] Add test coverage for SubscriptionInstanceList.__init_subclass__ (#402) * Add test coverage for SubscriptionInstanceList.__init_subclass__ * Set CODECOV_TOKEN * And unset CODECOV_TOKEN * Activated code-coverage token --------- Co-authored-by: Peter Boers --- .github/workflows/run-unit-tests.yml | 1 + test/unit_tests/domain/test_base.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 3bdae3fbc..5472ccbd4 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -92,5 +92,6 @@ jobs: - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} # gives error 'Could not find a repository associated with upload token' fail_ci_if_error: true files: ./coverage.xml diff --git a/test/unit_tests/domain/test_base.py b/test/unit_tests/domain/test_base.py index 893bb0778..f142c9472 100644 --- a/test/unit_tests/domain/test_base.py +++ b/test/unit_tests/domain/test_base.py @@ -1099,6 +1099,24 @@ class ListType(ConstrainedList): assert _is_constrained_list_type(List[int]) is False +def test_product_block_with_si_list(test_product_one): + """Test a SubscriptionInstanceList within a ProductBlockModel. + + This provides test coverage for SubscriptionInstanceList.__init_subclass__() + """ + + class ListOfValues(SubscriptionInstanceList[float]): + max_items = 3 + + class ProductBlockOneForTestInactive(ProductBlockModel, product_block_name="ProductBlockOneForTest"): + values: ListOfValues = Field(default_factory=list) + + block = ProductBlockOneForTestInactive( + subscription_instance_id=uuid4(), owner_subscription_id=uuid4(), values=["1.3", 2] + ) + assert block.dict()["values"] == [1.3, 2.0] + + def test_diff_in_db_empty(test_product_one, test_product_type_one): ProductTypeOneForTestInactive, _, _ = test_product_type_one