diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index a18b2d5..4804a16 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -4414,13 +4414,13 @@ def get_watch_list(session, obj): if watcher.user.username in users: users.remove(watcher.user.username) - # Add all the people watching this object, remove those who opted-out - for watcher in obj_watchers_query.all(): - if watcher.watch: - users.add(watcher.user.username) - else: - if watcher.user.username in users: - users.remove(watcher.user.username) + # Add all the people watching this object, remove those who opted-out + for watcher in obj_watchers_query.all(): + if watcher.watch: + users.add(watcher.user.username) + else: + if watcher.user.username in users: + users.remove(watcher.user.username) return users diff --git a/tests/test_pagure_lib_watch_list.py b/tests/test_pagure_lib_watch_list.py index 67edd29..a3a3892 100644 --- a/tests/test_pagure_lib_watch_list.py +++ b/tests/test_pagure_lib_watch_list.py @@ -460,6 +460,7 @@ class PagureLibGetWatchListtests(tests.Modeltests): set(['foo', 'bar', 'pingou']) ) + @mock.patch.dict('pagure.config.config', {'PAGURE_ADMIN_USERS': 'foo'}) def test_get_watch_list_project_w_private_issue(self): """ Test get_watch_list when the project has one contributor watching the project and the issue is private """ @@ -520,6 +521,19 @@ class PagureLibGetWatchListtests(tests.Modeltests): pagure.lib.get_watch_list(self.session, iss), set(['pingou']) ) + out = pagure.lib.set_watch_obj(self.session, 'foo', iss, True) + self.assertEqual(out, 'You are now watching this issue') + self.assertEqual( + pagure.lib.get_watch_list(self.session, iss), + set(['pingou','foo']) + ) + out = pagure.lib.set_watch_obj(self.session, 'foo', iss, False) + self.assertEqual( + out, 'You are no longer watching this issue') + self.assertEqual( + pagure.lib.get_watch_list(self.session, iss), + set(['pingou']) + ) if __name__ == '__main__':