def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) # Assert that there is no dupe news in two pages digests_set_1 = set([news['digest'] for news in news_page_1]) digests_set_2 = set([news['digest'] for news in news_page_2]) assert len(digests_set_1.intersection(digests_set_2)) == 0 print('test_getNewsSummariesForUser_pagination passed!')
def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) digest_page_1_set = set([news['digest'] for news in news_page_1]) digest_page_2_set = set([news['digest'] for news in news_page_2]) assert len(digest_page_1_set.intersection(digest_page_2_set)) == 0 print('test_getNewsSummariesForUser_pagination passed!')
def test_getNewsSummariesForUser_pagination(): # Test paginated data are different news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) # Assert that there is no dupe news in two pages digests_page_1_set = set([news['digest'] for news in news_page_1]) digests_page_2_set = set([news['digest'] for news in news_page_2]) assert len(digests_page_1_set.intersection(digests_page_2_set)) == 0 print("test_getNewsSummariesForUser_pagination passed!")
def test_getNewsSummariesForUser_pagniation(): news_page_1 = operations.getNewsSummariesForUser('test_user', 1) news_page_2 = operations.getNewsSummariesForUser('test_user', 2) print(len(news_page_1)) print(len(news_page_2)) assert len(news_page_1) > 0 assert len(news_page_2) > 0 digest_page_1_set = set([x['digest'] for x in news_page_1]) digest_page_2_set = set([x['digest'] for x in news_page_2]) assert len(digest_page_1_set.intersection(digest_page_2_set)) == 0 print('test_getNewsSummariesForUser_pagination passed')
def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) assert len(news_page_1) > 0 assert len(news_page_2) > 0 # Assert there is no duplicate news in two pages digests_page_1_set = Set([news['digest'] for news in news_page_1]) digests_page_2_set = Set([news['digest'] for news in news_page_2]) assert len(digests_page_1_set.intersection(digests_page_2_set)) == 0 print 'test_getNewsSummariesForUser_pagination passed!'
def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) assert len(news_page_1) > 0 assert len(news_page_2) > 0 digests_page_1_set = Set([news['digest'] for news in news_page_1]) digests_page_2_set = Set([news['digest'] for news in news_page_2]) assert len(digests_page_1_set.intersection(digests_page_2_set)) == 0 print 'test_getnres_page passed'
def test_getNewsSummariesForUser_pagination(): news1 = operations.getNewsSummariesForUser(userName, 1) news2 = operations.getNewsSummariesForUser(userName, 2) assert len(news1) > 0 assert len(news2) > 0 digest_page1 = set([news['digest'] for news in news1]) digest_page2 = set([news['digest'] for news in news2]) l = len(digest_page1.intersection(digest_page2)) assert l == 0 print('test_getNewsSummariesForUser_pagination passed!')
def test_getNewsSummairesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test_user', 1) news_page_2 = operations.getNewsSummariesForUser('test_user', 2) assert len(news_page_1) > 0 assert len(news_page_2) > 0 digests_page_1_set = set([news['digest'] for news in news_page_1]) digests_page_2_set = set([news['digest'] for news in news_page_2]) assert len(digests_page_1_set.intersection(digests_page_2_set)) == 0 assert len(digests_page_1_set.union(digests_page_2_set)) == (len(news_page_1) + len(news_page_2)) print('test_getNewsSummairesForUser_pagination passed!')
def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test', 1) news_page_2 = operations.getNewsSummariesForUser('test', 2) print(len(news_page_2)) assert len(news_page_1) > 0 assert len(news_page_2) > 0 # Assert that there's no duplication in two pages digests_page_1_set = set(list(map(lambda x: x['digest'], news_page_1))) digests_page_2_set = set(list(map(lambda x: x['digest'], news_page_2))) print(digests_page_1_set) print(digests_page_2_set) assert len(digests_page_1_set.intersection(digests_page_2_set)) == 0 print("pagination test passed!")
def getNewsSummariesForUser(self, user_id, page_num): # db = mongodb_client.get_db() # print(db,'dbs') # news = list(db['news'].find()) # print(news,"news123") # return json.loads(dumps(news)) return operations.getNewsSummariesForUser(user_id, page_num)
def test_getNewsSummariesForUser_basic(): news_list = operations.getNewsSummariesForUser('test_user', 1) print('first page has %d news' % len(news_list)) for news_entry in news_list: print(news_entry['description']) assert len(news_list) > 0 print("test_getNewsSummariesForUser_basic passed")
def test_getNewsSummariesForUser_pagination(): news_page_1 = operations.getNewsSummariesForUser('test_user', 1) news_page_2 = operations.getNewsSummariesForUser('test_user', 2) assert len(news_page_1) > 0 assert len(news_page_2) > 0 # test if news on page 1 overlap with those on page 2 digest_set_page_1 = set([news['digest'] for news in news_page_1]) digest_set_page_2 = set([news['digest'] for news in news_page_2]) for digest in digest_set_page_1: print(digest) assert len(digest_set_page_1.intersection(digest_set_page_2)) == 0 assert len(digest_set_page_1.union( digest_set_page_2)) == len(digest_set_page_1) + len(digest_set_page_2) print('test_getNewsSummariesForUser_pagination passed')
def test_getNewsSummariesForUser_click(): operations.logNewsClickForUser("user1", "news1") click_client.sleep(3) news = operations.getNewsSummariesForUser("user1", 1) for one_news in news: if one_news['class'] is not None: if one_news['class'] == 'World': assert one_news['reason'] == 'recommended' else: assert 'reason' not in one_news print('test_getNewsSummariesForUser_click passed!')
def getNewsSummariesForUser(self, user_id, page_num, user_ip): starttime = datetime.datetime.now() response = operations.getNewsSummariesForUser(user_id, page_num, user_ip) endtime = datetime.datetime.now() diff = int((endtime - starttime).microseconds/1000) # logging.basicConfig(level=logging.INFO, # format='%(asctime)s %(message)s', # datefmt='%a %d %b %Y %H:%M:%S' + ',', # filename='../logging/user_requests_' + time.strftime('%m-%d-%Y', time.localtime()) +'.log', # filemode='a') # logging.info( # 'operations.getNewsSummariesForUser' + ', ' + # str(diff) + ' ms, ' + # 'event_name : ' + 'news_list_request' + ', ' + # 'user_id : ' + str(user_id) + ', ' + # 'user_ip : ' + str(user_ip)) print response return response
def test_getNewsSummariesForUser_invalid_pageNum(): news = operations.getNewsSummariesForUser('*****@*****.**', -1) assert len(news) == 0 print('test_getNewsSummariesForUser_invalid_pageNum passed!')
def getNewsSummariesForUser(user_id, page_num): """Get news summary from mongodb""" print("hello") return operations.getNewsSummariesForUser(user_id, page_num)
def test_getNewsSummariesForUser_Basic(): news = operations.getNewsSummariesForUser('test', 1) print news assert len(news) > 0 print "test_getNewsSummariesForUser_Basic passed"
def test_getNewsSummariesForUserLargePage_num(): news = operations.getNewsSummariesForUser('test_user', 1000) assert len(news) == 0 print('test_get_news_summaries_for_user_large_page_num passed!')
def test_getNewsSummariesForUserInvalidPage_num(): news = operations.getNewsSummariesForUser('test_user', -1) assert len(news) == 0 print('test_get_news_summaries_for_user_invalid_page_num passed!')
def test_getNewsSummariesForUserBasic(): news = operations.getNewsSummariesForUser('test_user', 1) print(news) assert len(news) > 0 print('test_get_news_summaries_for_user_basic passed!')
def getNewsSummariesForUser(user_id, page_num): print('ddddd') return operations.getNewsSummariesForUser(user_id, page_num)
def getNewsSummariesForUser(self, user_id, page_num): # pylint: disable=no-self-use """ Get news summaries for a user. """ print "getNewsSummariesForUser is called with %s and %s" % (user_id, page_num) return operations.getNewsSummariesForUser(user_id, page_num)
def getNewsSummariesForUser(self, user_id, page_num): logging.info('backend_server: %s asks for page %s' % (user_id, page_num)) return operations.getNewsSummariesForUser(user_id, page_num)
def getNewsSummariesForUser(self, user_id, page_num): logger.info('calling backend_server getNewsSummariesForUser') return operations.getNewsSummariesForUser(user_id, page_num)
def test_getNewsSummariesForUser_basic(): news = operations.getNewsSummariesForUser('test', 1) assert len(news) > 0 print('test_getNewsSummariesForUser_basic passed!')
def get_news_summaries_for_user(user_id, page_num): print(("get_news_summaries_for_user is called with %s and %s" % (user_id, page_num))) return operations.getNewsSummariesForUser(user_id, page_num)
def test_getNewsSummariesForUser_basic(): news = operations.getNewsSummariesForUser('*****@*****.**', 1) print news assert len(news) > 0 print 'test_getNewsSummariesForUser_basic passed!'
def getNewsSummariesForUser(self, user_id, page_num): logger.info('get news summaries for user') return operations.getNewsSummariesForUser(user_id, page_num)
def test_getNewsSummariesForUser_large_pageNum(): news = operations.getNewsSummariesForUser('*****@*****.**', 1000) assert len(news) == 0 print('test_getNewsSummariesForUser_large_pageNum passed!')
def getNewsSummariesForUser(self, user_id, page_num): return operations.getNewsSummariesForUser(user_id, page_num)
def getNewsSummariesForUser(user_id, page_num): """ Get news summaries for a user """ LOGGER.debug("getNewsSummariesForUser is called with %s and %s", user_id, page_num) return operations.getNewsSummariesForUser(user_id, page_num)