def setup_function(): Account.clear_cache() Comment.clear_cache() Location.clear_cache() Media.clear_cache() Story.clear_cache() Tag.clear_cache()
def test_update_tag(web_agent, name): tag = Tag(name) data = web_agent.update(tag) assert data is not None assert tag.name is not None assert tag.media_count is not None assert tag.top_posts
def test_get_media_tag_pointer(web_agent, delay, count, name): tag = Tag(name) pointer = None data = [] for _ in range(count): tmp, pointer = web_agent.get_media(tag, pointer=pointer) time.sleep(delay) data.extend(tmp) assert (pointer is None) == (tag.media_count == len(data))
def test_clear_cache_tag(id): tag = Tag(id) assert Tag.cache == {id: tag} Tag.clear_cache() assert Tag.cache == dict()
def teardown_function(): Account.clear_cache() Media.clear_cache() Location.clear_cache() Tag.clear_cache()
def test_get_media_tag(web_agent, delay, count, name): tag = Tag(name) data, pointer = web_agent.get_media(tag, count=count, delay=delay) assert min(tag.media_count, count) == len(data) assert (pointer is None) == (tag.media_count <= count)
def test_tag_creation(id): tag = Tag(id) assert getattr(tag, tag.primary_key) == id assert len(Tag.cache) == 1 and Tag.cache[id] is tag