| |
@@ -7,9 +7,8 @@
|
| |
|
| |
from hubs.app import app
|
| |
from hubs.models import User, Hub, Association
|
| |
- from hubs.feed import (
|
| |
- Notifications, Activity, add_notif_id, format_msgs, get_hubs_for_msg,
|
| |
- on_new_message, on_new_notification)
|
| |
+ from hubs.feed import (Activity, add_notif_id, format_msgs,
|
| |
+ get_hubs_for_msg, on_new_message)
|
| |
from hubs.tests import APPTest
|
| |
|
| |
|
| |
@@ -18,7 +17,6 @@
|
| |
def setUp(self):
|
| |
super(FeedTest, self).setUp()
|
| |
self.feed_classes = [
|
| |
- (Notifications, "notif"),
|
| |
(Activity, "activity"),
|
| |
]
|
| |
|
| |
@@ -67,9 +65,7 @@
|
| |
feed.db.insert_one.assert_called_once()
|
| |
insert_call_args = feed.db.insert_one.call_args_list[0][0]
|
| |
inserted_msg = json.loads(insert_call_args[0]["msg"])
|
| |
- if feed_class == Notifications:
|
| |
- self.assertIn("msg_ids", inserted_msg)
|
| |
- elif feed_class == Activity:
|
| |
+ if feed_class == Activity:
|
| |
self.assertEqual(inserted_msg, msg)
|
| |
|
| |
def test_length(self):
|
| |
@@ -100,28 +96,6 @@
|
| |
self.assertEqual(feed.add.call_count, 2)
|
| |
feed.add.assert_called_with(msg)
|
| |
|
| |
- @patch("hubs.feed.Notifications")
|
| |
- def test_on_new_notification(self, mock_notifications):
|
| |
- feed = Mock()
|
| |
- mock_notifications.return_value = feed
|
| |
- msg = {"msg_id": "testmsg"}
|
| |
- with patch("hubs.feed.fedmsg.meta.msg2agent") as msg2agent:
|
| |
- msg2agent.return_value = "ralph"
|
| |
- on_new_notification(msg)
|
| |
- msg2agent.assert_called()
|
| |
- stream = Hub.by_name("ralph", "stream")
|
| |
- mock_notifications.assert_called_with(stream.id)
|
| |
- feed.add.assert_called_with(msg)
|
| |
-
|
| |
- @patch("hubs.feed.Notifications")
|
| |
- def test_on_new_notification_unknown_user(self, mock_notifications):
|
| |
- with patch("hubs.feed.fedmsg.meta.msg2agent") as msg2agent:
|
| |
- msg2agent.return_value = "unknown_user"
|
| |
- on_new_notification({"msg_id": "testmsg"})
|
| |
- msg2agent.assert_called()
|
| |
- # User does not exist, no feed instance should have been created.
|
| |
- mock_notifications.assert_not_called()
|
| |
-
|
| |
def test_add_notif_id(self):
|
| |
msg = {
|
| |
"msg_ids": {
|
| |
As discussed on IRC, this is to be dropped.