def setup_function(): Account.clear_cache() Comment.clear_cache() Location.clear_cache() Media.clear_cache() Story.clear_cache() Tag.clear_cache()
def test_get_media_account(web_agent, delay, count, username): account = Account(username) data, pointer = web_agent.get_media( account, count=count, delay=delay, ) assert min(account.media_count, count) == len(data) assert (pointer is None) == (account.media_count <= count)
def test_get_media_account_pointer(web_agent, delay, count, username): account = Account(username) pointer = None data = [] for _ in range(count): tmp, pointer = web_agent.get_media(account, pointer=pointer) time.sleep(delay) data.extend(tmp) assert (pointer is None) == (account.media_count == len(data))
def test_clear_cache_comment(id): account = Account("test") media = Media("test") comment = Comment(id, media=media, owner=account, text="test", created_at=0) assert Comment.cache == {id: comment} Comment.clear_cache() assert Comment.cache == dict() assert Media.cache == {"test": media} assert Account.cache == {"test": account}
def test_comment_creation(id): account = Account("test") media = Media("test") comment = Comment(id, media=media, owner=account, text="test", created_at=0) assert getattr(comment, comment.primary_key) == id assert comment.media is media assert comment.owner is account assert comment.text == "test" assert comment.created_at == 0 assert len(Comment.cache) == 1 and Comment.cache[id] is comment
def test_update_account(web_agent, username): account = Account(username) data = web_agent.update(account) assert data is not None assert account.id is not None assert account.full_name is not None assert account.profile_pic_url is not None assert account.profile_pic_url_hd is not None assert account.biography is not None assert account.follows_count is not None assert account.followers_count is not None assert account.media_count is not None assert account.is_private is not None assert account.is_verified is not None assert account.country_block is not None
def test_clear_cache_account(id): account = Account(id) assert Account.cache == {id: account} Account.clear_cache() assert Account.cache == dict()
def teardown_function(): Account.clear_cache() Media.clear_cache() Location.clear_cache() Tag.clear_cache()
async def test_update_account(async_mobile_account_agent, username): account = Account(username) response = await async_mobile_account_agent.update(account)
def test_account_creation(id): account = Account(id) assert getattr(account, account.primary_key) == id assert len(Account.cache) == 1 and Account.cache[id] is account