Skip to content

Commit

Permalink
Widen the schema_sync test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksamies committed Sep 3, 2024
1 parent d9937f8 commit 780a269
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions django/thunderstore/schema_import/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
PackageCategory,
PackageListingSection,
)
from thunderstore.community.models.package_listing import PackageListing
from thunderstore.repository.models import PackageInstaller
from thunderstore.schema_import.schema import Schema, SchemaPackageInstaller
from thunderstore.schema_import.sync import (
Expand All @@ -30,22 +31,31 @@ def test_schema_sync():
assert Community.objects.count() == 0
assert PackageCategory.objects.count() == 0
assert PackageListingSection.objects.count() == 0
assert PackageListing.objects.filter(is_auto_imported=True).count() == 0

sync_ecosystem_schema.delay()

com_count = Community.objects.count()
cat_count = PackageCategory.objects.count()
sec_count = PackageListingSection.objects.count()
autolisted_pkg_count = PackageListing.objects.filter(is_auto_imported=True).count()

assert com_count > 0
assert cat_count > 0
assert sec_count > 0
# TODO: Uncomment when schema has autolisted packages
# assert autolisted_pkg_count > 0

# Ensure idempotency
sync_ecosystem_schema.delay()

assert com_count == Community.objects.count()
assert cat_count == PackageCategory.objects.count()
assert sec_count == PackageListingSection.objects.count()
assert (
autolisted_pkg_count
== PackageListing.objects.filter(is_auto_imported=True).count()
)


@pytest.mark.django_db
Expand Down

0 comments on commit 780a269

Please sign in to comment.