def test_user_oper(self): user_list = list() for fake_id in FAKE_IDS: user_list.append(User(fake_id)) UserOper.add_all(user_list) rs = db_session.execute('select * from {}'.format(wbuser.name)) assert rs.rowcount > 0 assert UserOper.get_user_by_uid('5') is None assert UserOper.get_user_by_uid(FAKE_ID) is not None
def get_user_profile(user_id): """ :param user_id: uid :return: user info and is crawled or not """ user = UserOper.get_user_by_uid(user_id) if user: storage.info('user {id} has already crawled'.format(id=user_id)) else: user = get_url_from_web(user_id) return user
def get_profile(user_id): """ :param user_id: uid :return: user info and is crawled or not """ user = UserOper.get_user_by_uid(user_id) if user: storage.info('user {id} has already crawled'.format(id=user_id)) SeedidsOper.set_seed_crawled(user_id, 1) is_crawled = 1 else: user = get_url_from_web(user_id) if user is not None: SeedidsOper.set_seed_crawled(user_id, 1) else: SeedidsOper.set_seed_crawled(user_id, 2) is_crawled = 0 return user, is_crawled