@@ -100,16 +100,33 @@ def test_add_activity(self):
100100 self .assertEqual (activities [0 ]['id' ], activity_id )
101101
102102 def test_add_activity_to (self ):
103+ # test for sending an activities to the team feed using to
104+ feeds = ['user' , 'team' , 'team_follower' ]
105+ user_feed , team_feed , team_follower_feed = map (lambda x : getfeed ('user' , x ), feeds )
106+ team_follower_feed .follow (team_feed .slug , team_feed .user_id )
103107 activity_data = {
104108 'actor' : 1 , 'verb' : 'tweet' , 'object' : 1 ,
105- 'to' : [getfeed ( 'user' , 'pyto1' ) .id ]
109+ 'to' : [team_feed .id ]
106110 }
107- response = self .user1 .add_activity (activity_data )
108- feed = getfeed ('user' , 'pyto1' )
111+ response = user_feed .add_activity (activity_data )
109112 activity_id = response ['id' ]
110- activities = feed .get (limit = 1 )['results' ]
113+ # see if the new activity is also in the team feed
114+ activities = team_feed .get (limit = 1 )['results' ]
111115 self .assertEqual (activities [0 ]['id' ], activity_id )
112-
116+ self .assertEqual (activities [0 ]['origin' ], team_feed .id )
117+ # see if the fanout process also works
118+ activities = team_follower_feed .get (limit = 1 )['results' ]
119+ self .assertEqual (activities [0 ]['id' ], activity_id )
120+ self .assertEqual (activities [0 ]['origin' ], team_feed .id )
121+ # and validate removing also works
122+ self .user1 .remove_activity (response ['id' ])
123+ # check the user pyto feed
124+ activities = team_feed .get (limit = 1 )['results' ]
125+ self .assertNotEqual (activities [0 ]['id' ], activity_id )
126+ # and the flat feed
127+ activities = team_follower_feed .get (limit = 1 )['results' ]
128+ self .assertNotEqual (activities [0 ]['id' ], activity_id )
129+
113130 def test_remove_activity (self ):
114131 activity_data = {'actor' : 1 , 'verb' : 'tweet' , 'object' : 1 }
115132 activity_id = self .user1 .add_activity (activity_data )['id' ]
@@ -160,7 +177,7 @@ def test_add_activities_to(self):
160177 get_activity_ids = [a ['id' ] for a in activities ]
161178 self .assertEqual (get_activity_ids , activity_ids [::- 1 ])
162179
163- def test_follow (self ):
180+ def test_follow_and_source (self ):
164181 feed = getfeed ('user' , 'test_follow' )
165182 agg_feed = getfeed ('aggregated' , 'test_follow' )
166183 actor_id = random .randint (10 , 100000 )
@@ -171,6 +188,7 @@ def test_follow(self):
171188 activities = agg_feed .get (limit = 3 )['results' ]
172189 activity = self ._get_first_aggregated_activity (activities )
173190 activity_id_found = activity ['id' ] if activity is not None else None
191+ self .assertEqual (activity ['origin' ], feed .id )
174192 self .assertEqual (activity_id_found , activity_id )
175193
176194 def test_follow_private (self ):
0 commit comments