Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update_repository(
log.info(f"Signal triggered for repository {instance.repoid}")
created: bool = kwargs["created"]
changes: Dict[str, Any] = instance.tracker.changed()
tracked_fields: List[str] = ["name", "upload_token"]
tracked_fields: List[str] = ["name", "upload_token", "activated", "active"]

if created or any([field in changes for field in tracked_fields]):
data = {
Expand Down
20 changes: 18 additions & 2 deletions core/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def test_shelter_repo_sync(mocker):
publish = mocker.patch("google.cloud.pubsub_v1.PublisherClient.publish")

# this triggers the publish via Django signals
repo = RepositoryFactory(repoid=91728376, author=OwnerFactory(ownerid=555))
repo = RepositoryFactory(
repoid=91728376, author=OwnerFactory(ownerid=555), active=False, activated=False
)

# triggers publish on create
publish.assert_has_calls(
Expand Down Expand Up @@ -38,13 +40,27 @@ def test_shelter_repo_sync(mocker):
b'{"type": "repo", "sync": "one", "id": 91728376}',
)

# Does not trigger another publish with untracked field
repo.message = "foo"
repo.save()

publish_calls = publish.call_args_list
# does not trigger another publish
assert len(publish_calls) == 3

# Triggers call when active is changed
repo.active = True
repo.save()

publish_calls = publish.call_args_list
assert len(publish_calls) == 4

# Triggers call when activated is changed
repo.activated = True
repo.save()

publish_calls = publish.call_args_list
assert len(publish_calls) == 5


@pytest.mark.django_db
def test_shelter_commit_sync(mocker):
Expand Down
Loading