Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 169b808

Browse files
Add active + activated to repo signals
1 parent 8fa8e1c commit 169b808

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

core/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def update_repository(
1818
log.info(f"Signal triggered for repository {instance.repoid}")
1919
created: bool = kwargs["created"]
2020
changes: Dict[str, Any] = instance.tracker.changed()
21-
tracked_fields: List[str] = ["name", "upload_token"]
21+
tracked_fields: List[str] = ["name", "upload_token", "activated", "active"]
2222

2323
if created or any([field in changes for field in tracked_fields]):
2424
data = {

core/tests/test_signals.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def test_shelter_repo_sync(mocker):
1010
publish = mocker.patch("google.cloud.pubsub_v1.PublisherClient.publish")
1111

1212
# this triggers the publish via Django signals
13-
repo = RepositoryFactory(repoid=91728376, author=OwnerFactory(ownerid=555))
13+
repo = RepositoryFactory(
14+
repoid=91728376, author=OwnerFactory(ownerid=555), active=False, activated=False
15+
)
1416

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

43+
# Does not trigger another publish with untracked field
4144
repo.message = "foo"
4245
repo.save()
4346

4447
publish_calls = publish.call_args_list
45-
# does not trigger another publish
4648
assert len(publish_calls) == 3
4749

50+
# Triggers call when active is changed
51+
repo.active = True
52+
repo.save()
53+
54+
publish_calls = publish.call_args_list
55+
assert len(publish_calls) == 4
56+
57+
# Triggers call when activated is changed
58+
repo.activated = True
59+
repo.save()
60+
61+
publish_calls = publish.call_args_list
62+
assert len(publish_calls) == 5
63+
4864

4965
@pytest.mark.django_db
5066
def test_shelter_commit_sync(mocker):

0 commit comments

Comments
 (0)