def test_timeline_cursor(self): topic = PersonalizedStream.create_or_update_topic(self.network, '1', 'UN') cursor = TimelineCursor.init(self.network, topic.topic_id +":topicStream", 50, datetime.datetime.now()) data = PersonalizedStream.get_timeline_stream(cursor, True) self.assertTrue(data) PersonalizedStream.delete_topic(self.network, topic)
def get_topic_stream_cursor(core, topic, limit=50, date=datetime.now()): resource = topic.topic_id + ":topicStream" return TimelineCursor.init(core, resource, limit, date)
def test_build_cursor(self): network = Livefyre.get_network(self.NETWORK_NAME, self.NETWORK_KEY) date = datetime.datetime.now() cursor = TimelineCursor(network, CursorData("resource", 50, date)) self.assertTrue(cursor) cursor.data.set_cursor_time(date) self.assertTrue(cursor.data.cursor_time) if pyver < 2.7: pass elif pyver < 3.0: with self.assertRaisesRegexp(AssertionError, 'resource is missing'): TimelineCursor.init(network, None, 50, datetime.datetime.now()) with self.assertRaisesRegexp(AssertionError, 'limit is missing'): TimelineCursor.init(network, 'resource', None, datetime.datetime.now()) with self.assertRaisesRegexp(AssertionError, 'cursor_time is missing'): TimelineCursor.init(network, 'resource', 50, None) else: with self.assertRaisesRegex(AssertionError, 'resource is missing'): TimelineCursor.init(network, None, 50, datetime.datetime.now()) with self.assertRaisesRegex(AssertionError, 'limit is missing'): TimelineCursor.init(network, 'resource', None, datetime.datetime.now()) with self.assertRaisesRegex(AssertionError, 'cursor_time is missing'): TimelineCursor.init(network, 'resource', 50, None)
def get_personal_stream_cursor(network, user, limit=50, date=datetime.now()): resource = network.get_urn_for_user(user) +":personalStream" return TimelineCursor.init(network, resource, limit, date)