Skip to content

Commit

Permalink
Implement is_removed tests
Browse files Browse the repository at this point in the history
Implement tests for is_removed properties in Package and
PackageVersion.

Refs. TS-2275
  • Loading branch information
Roffenlund committed Jan 10, 2025
1 parent 0efd6fc commit 323a132
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
23 changes: 22 additions & 1 deletion django/thunderstore/repository/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from thunderstore.community.factories import PackageCategoryFactory, SiteFactory
from thunderstore.community.models.package_listing import PackageListing
from thunderstore.core.types import UserType
from thunderstore.repository.factories import PackageFactory
from thunderstore.repository.factories import PackageFactory, PackageVersionFactory
from thunderstore.repository.models import (
Namespace,
Package,
Expand Down Expand Up @@ -224,3 +224,24 @@ def test_package_update_listing(
assert listing.categories.count() == 3
for entry in cats:
assert entry in listing.categories.all()


@pytest.mark.django_db
@pytest.mark.parametrize(
("package_is_active", "version_is_active", "expected_is_removed"),
(
(False, False, True),
(True, False, True),
(False, True, True),
(True, True, False),
),
)
def test_package_is_removed(
package_is_active: bool,
version_is_active: bool,
expected_is_removed: bool,
) -> None:
package = PackageFactory(is_active=package_is_active)
PackageVersionFactory(package=package, is_active=version_is_active)

assert package.is_removed == expected_is_removed
21 changes: 21 additions & 0 deletions django/thunderstore/repository/tests/test_package_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,24 @@ def test_package_version_is_effectively_active(
version = PackageVersionFactory(package=package, is_active=version_is_active)

assert version.is_effectively_active == (package_is_active and version_is_active)


@pytest.mark.django_db
@pytest.mark.parametrize(
("package_is_active", "version_is_active", "expected_is_removed"),
(
(False, False, True),
(True, False, True),
(False, True, True),
(True, True, False),
),
)
def test_package_version_is_removed(
package_is_active: bool,
version_is_active: bool,
expected_is_removed: bool,
) -> None:
package = PackageFactory(is_active=package_is_active)
version = PackageVersionFactory(package=package, is_active=version_is_active)

assert version.is_removed == expected_is_removed

0 comments on commit 323a132

Please sign in to comment.