Skip to content

Commit ae8f192

Browse files
3341 add private and author to shelter sync (#1145)
1 parent da2923f commit ae8f192

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

core/signals.py

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

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

core/tests/test_signals.py

+17-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_shelter_repo_sync(mocker):
1111

1212
# this triggers the publish via Django signals
1313
repo = RepositoryFactory(
14-
repoid=91728376, author=OwnerFactory(ownerid=555), active=False, activated=False
14+
repoid=91728376, author=OwnerFactory(ownerid=555), private=False
1515
)
1616

1717
# triggers publish on create
@@ -47,19 +47,28 @@ def test_shelter_repo_sync(mocker):
4747
publish_calls = publish.call_args_list
4848
assert len(publish_calls) == 3
4949

50-
# Triggers call when active is changed
51-
repo.active = True
50+
# Triggers call when owner is changed
51+
repo.author = OwnerFactory(ownerid=888)
5252
repo.save()
5353

5454
publish_calls = publish.call_args_list
55-
assert len(publish_calls) == 4
55+
# 1 is for the new owner created
56+
assert len(publish_calls) == 5
57+
publish.assert_has_calls(
58+
[
59+
call(
60+
"projects/test-project-id/topics/test-topic-id",
61+
b'{"type": "owner", "sync": "one", "id": 888}',
62+
),
63+
]
64+
)
5665

57-
# Triggers call when activated is changed
58-
repo.activated = True
66+
# Triggers call when private is changed
67+
repo.private = True
5968
repo.save()
6069

61-
publish_calls = publish.call_args_list
62-
assert len(publish_calls) == 5
70+
# publish_calls = publish.call_args_list
71+
assert len(publish_calls) == 6
6372

6473

6574
@pytest.mark.django_db

0 commit comments

Comments
 (0)