Esempio n. 1
0
def setup_function():
    Account.clear_cache()
    Comment.clear_cache()
    Location.clear_cache()
    Media.clear_cache()
    Story.clear_cache()
    Tag.clear_cache()
Esempio n. 2
0
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)
Esempio n. 3
0
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))
Esempio n. 4
0
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}
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
def test_clear_cache_account(id):
    account = Account(id)
    assert Account.cache == {id: account}

    Account.clear_cache()
    assert Account.cache == dict()
Esempio n. 8
0
def teardown_function():
    Account.clear_cache()
    Media.clear_cache()
    Location.clear_cache()
    Tag.clear_cache()
Esempio n. 9
0
async def test_update_account(async_mobile_account_agent, username):
    account = Account(username)
    response = await async_mobile_account_agent.update(account)
Esempio n. 10
0
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