4
4
from stream .exceptions import ApiKeyException , InputException
5
5
import random
6
6
import jwt
7
- from unittest .case import TestCase
7
+ try :
8
+ from unittest .case import TestCase
9
+ except ImportError :
10
+ from unittest import TestCase
8
11
import json
9
12
10
13
import os
@@ -42,6 +45,7 @@ def connect_debug():
42
45
location = 'us-east' ,
43
46
timeout = 30 ,
44
47
base_url = 'http://qa-api.getstream.io/api/' ,
48
+ # base_url='http://localhost-api.getstream.io:8000/api/',
45
49
)
46
50
47
51
client = connect_debug ()
@@ -308,16 +312,14 @@ def test_add_activity_to(self):
308
312
activities = team_follower_feed .get (limit = 1 )['results' ]
309
313
self .assertFirstActivityIDNotEqual (activities , activity_id )
310
314
311
-
312
315
def test_add_activity_to_type_error (self ):
313
316
user_feed = getfeed ('user' , '1' )
314
317
activity_data = {
315
318
'actor' : 1 , 'verb' : 'tweet' , 'object' : 1 ,
316
319
'to' : 'string'
317
320
}
318
321
319
- with self .assertRaises (TypeError ):
320
- user_feed .add_activity (activity_data )
322
+ self .assertRaises (TypeError , user_feed .add_activity , activity_data )
321
323
322
324
def assertFirstActivityIDEqual (self , activities , correct_activity_id ):
323
325
activity_id = None
@@ -610,7 +612,6 @@ def test_get_not_marked_seen(self):
610
612
print (notification_feed .add_activity ({'actor' : 2 , 'verb' : 'tweet' , 'object' : 2 })['id' ])
611
613
print (notification_feed .add_activity ({'actor' : 3 , 'verb' : 'tweet' , 'object' : 3 })['id' ])
612
614
613
-
614
615
activities = notification_feed .get (limit = 3 )['results' ]
615
616
from pprint import pprint
616
617
print (len (activities ))
@@ -658,7 +659,6 @@ def test_mark_read_by_id(self):
658
659
print (notification_feed .add_activity ({'actor' : 2 , 'verb' : 'tweet' , 'object' : 2 })['id' ]) # ['id']
659
660
print (notification_feed .add_activity ({'actor' : 3 , 'verb' : 'tweet' , 'object' : 2 })['id' ]) # ['id']
660
661
661
-
662
662
activities = notification_feed .get (limit = 3 )['results' ]
663
663
ids = []
664
664
from pprint import pprint
@@ -822,6 +822,12 @@ def test_serialization(self):
822
822
loaded = serializer .loads (serialized )
823
823
self .assertEqual (data , loaded )
824
824
825
+ # def test_signed_request_post(self):
826
+ # self.c._make_signed_request('post', 'test/auth/digest/', {}, {})
827
+ #
828
+ # def test_signed_request_get(self):
829
+ # self.c._make_signed_request('post', 'test/auth/digest/', {}, {})
830
+
825
831
def test_follow_many (self ):
826
832
sources = [getfeed ('user' , str (i )).id for i in range (10 )]
827
833
targets = [getfeed ('flat' , str (i )).id for i in range (10 )]
@@ -831,14 +837,14 @@ def test_follow_many(self):
831
837
for target in targets :
832
838
follows = self .c .feed (* target .split (':' )).followers ()['results' ]
833
839
self .assertEqual (len (follows ), 1 )
834
- self .assertIn (follows [0 ]['feed_id' ], sources )
840
+ self .assertTrue (follows [0 ]['feed_id' ] in sources )
835
841
self .assertEqual (follows [0 ]['target_id' ], target )
836
842
837
843
for source in sources :
838
844
follows = self .c .feed (* source .split (':' )).following ()['results' ]
839
845
self .assertEqual (len (follows ), 1 )
840
846
self .assertEqual (follows [0 ]['feed_id' ], source )
841
- self .assertIn (follows [0 ]['target_id' ], targets )
847
+ self .assertTrue (follows [0 ]['target_id' ] in targets )
842
848
843
849
def test_follow_many_acl (self ):
844
850
sources = [getfeed ('user' , str (i )) for i in range (10 )]
@@ -933,8 +939,6 @@ def test_create_email_redirect(self):
933
939
934
940
self .assertEqual (json .loads (qs ['events' ][0 ]), events )
935
941
936
-
937
-
938
942
def test_email_redirect_invalid_target (self ):
939
943
engagement = {'foreign_id' : 'tweet:1' , 'label' : 'click' , 'position' : 3 , 'user_id' : 'tommaso' , 'location' : 'email' , 'feed_id' : 'user:global' }
940
944
impression = {'foreign_ids' : ['tweet:1' , 'tweet:2' , 'tweet:3' , 'tweet:4' , 'tweet:5' ], 'user_id' :
0 commit comments