Skip to content

Commit

Permalink
Add test coverage for SubscriptionInstanceList.__init_subclass__ (#402)
Browse files Browse the repository at this point in the history
* Add test coverage for SubscriptionInstanceList.__init_subclass__

* Set CODECOV_TOKEN

* And unset CODECOV_TOKEN

* Activated code-coverage token

---------

Co-authored-by: Peter Boers <peter.boers@surf.nl>
  • Loading branch information
Mark90 and pboers1988 authored Oct 26, 2023
1 parent 60e5d61 commit d4bd5d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions test/unit_tests/domain/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d4bd5d6

Please sign in to comment.