def setup_function(): Account.clear_cache() Comment.clear_cache() Location.clear_cache() Media.clear_cache() Story.clear_cache() Tag.clear_cache()
def setup_function(): Account.clear_cache() Media.clear_cache() Location.clear_cache() Tag.clear_cache() if not anon["global_delay"] is None: min_delay = anon["global_delay"].get("min", 0) max_delay = anon["global_delay"].get("max", 120) sleep(random() * (max_delay - min_delay) + min_delay)
def test_get_media_location(agent, delay, settings, count, id): location = Location(id) data, pointer = agent.get_media(location, count=count, delay=delay, settings=settings) assert min(location.media_count, count) == len(data) assert (pointer is None) == (location.media_count <= count)
async def test_async_get_media_location_pointer(async_agent, delay, settings, count, id): location = Location(id) pointer = None data = [] for _ in range(count): tmp, pointer = await async_agent.get_media(location, pointer=pointer, settings=settings) await asyncio.sleep(delay) data.extend(tmp) assert (pointer is None) == (location.media_count == len(data))
async def test_async_update_location(async_agent, settings, id): location = Location(id) data = await async_agent.update(location, settings=settings) assert not data is None assert not location.id is None assert not location.slug is None assert not location.name is None assert not location.has_public_page is None assert not location.coordinates is None assert not location.media_count is None
def get_top_location_posts_json(locationId): agent = None parsedPosts = [] try: agent = WebAgent() location = Location(locationId) agent.update(location) posts = agent.get_media(location, count=3)[0] parsedPosts = _get_list_of_parsed_posts(agent, posts, True) except: print("error while getting account info") top_location_posts_json = jsonpickle.encode(parsedPosts, unpicklable=False) return top_location_posts_json
def test_clear_cache_location(id): location = Location(id) assert Location.cache == {id: location} Location.clear_cache() assert Location.cache == dict()