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 = cast(bool, kwargs["created"])
changes: Dict[str, Any] = instance.tracker.changed()
tracked_fields: List[str] = ["name", "upload_token", "activated", "active"]
tracked_fields: List[str] = ["name", "upload_token", "author_id", "private"]

if created or any(field in changes for field in tracked_fields):
data = {
Expand Down
25 changes: 17 additions & 8 deletions core/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_shelter_repo_sync(mocker):

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

# triggers publish on create
Expand Down Expand Up @@ -47,19 +47,28 @@ def test_shelter_repo_sync(mocker):
publish_calls = publish.call_args_list
assert len(publish_calls) == 3

# Triggers call when active is changed
repo.active = True
# Triggers call when owner is changed
repo.author = OwnerFactory(ownerid=888)
repo.save()

publish_calls = publish.call_args_list
assert len(publish_calls) == 4
# 1 is for the new owner created
assert len(publish_calls) == 5
publish.assert_has_calls(
[
call(
"projects/test-project-id/topics/test-topic-id",
b'{"type": "owner", "sync": "one", "id": 888}',
),
]
)

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

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


@pytest.mark.django_db
Expand Down
Loading