Exemplo n.º 1
0
def setup_function():
    Account.clear_cache()
    Comment.clear_cache()
    Location.clear_cache()
    Media.clear_cache()
    Story.clear_cache()
    Tag.clear_cache()
Exemplo n.º 2
0
def test_get_stories(login, password):
    agent = AgentAccount(login, password)

    data = agent.stories()

    Account.clear_cache()
    Story.clear_cache()
Exemplo n.º 3
0
def test_get_feed_long(login, password, count):
    agent = AgentAccount(login, password)

    data, pointer = agent.feed(count=count)

    assert (count >= len(data))

    Account.clear_cache()
Exemplo n.º 4
0
def test_update(login, password):
    agent = AgentAccount(login, password)

    agent.update()

    assert (not getattr(agent, "id") is None)

    Account.clear_cache()
Exemplo n.º 5
0
def test_follow_unfollow(login, password, username):
    agent = AgentAccount(login, password)
    account = Account(username)

    assert (agent.follow(account))
    assert (agent.unfollow(account))

    Account.clear_cache()
Exemplo n.º 6
0
def test_like_unlike_video(login, password, shortcode):
    agent = AgentAccount(login, password)
    video = Media(shortcode)

    assert (agent.like(video))
    assert (agent.unlike(video))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 7
0
def test_like_unlike_photo_set(login, password, shortcode):
    agent = AgentAccount(login, password)
    photo_set = Media(shortcode)

    assert (agent.like(photo_set))
    assert (agent.unlike(photo_set))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 8
0
def test_update_account(login, password, username):
    agent = AgentAccount(login, password)
    account = Account(username)

    data = agent.update(account)

    assert (not data is None)

    Account.clear_cache()
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
def test_get_followers_long(login, password, count, username):
    agent = AgentAccount(login, password)
    account = Account(username)

    data, pointer = agent.get_followers(account, count=count)

    assert (min(account.followers_count, count) == len(data))
    assert ((pointer is None) == (account.followers_count <= count))

    Account.clear_cache()
Exemplo n.º 11
0
def test_comment(login, password, shortcode):
    agent = AgentAccount(login, password)
    media = Media(shortcode)

    comment = agent.add_comment(media, "test")
    agent.delete_comment(comment)

    Account.clear_cache()
    Media.clear_cache()
    Comment.clear_cache()
Exemplo n.º 12
0
def test_get_feed_pointer(login, password, count):
    agent = AgentAccount(login, password)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = agent.feed(pointer=pointer)
        data.extend(tmp)

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 13
0
def test_get_media_account(login, password, count, username):
    agent = AgentAccount(login, password)
    account = Account(username)

    data, pointer = agent.get_media(account, count=count)

    assert (min(account.media_count, count) == len(data))
    assert ((pointer is None) == (account.media_count <= count))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 14
0
def test_get_media_account(count, username):
    anon = Agent()
    account = Account(username)

    data, pointer = anon.get_media(account, count=count)

    assert (min(account.media_count, count) == len(data))
    assert ((pointer is None) == (account.media_count <= count))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 15
0
def test_get_followers_pointer(login, password, count, username):
    agent = AgentAccount(login, password)
    account = Account(username)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = agent.get_followers(account, pointer=pointer)
        data.extend(tmp)

    assert ((pointer is None) == (account.followers_count <= count))

    Account.clear_cache()
Exemplo n.º 16
0
def test_get_likes_pointer(login, password, count, shortcode):
    agent = AgentAccount(login, password)
    media = Media(username)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = agent.get_likes(media, pointer=pointer)
        data.extend(tmp)

    assert ((pointer is None) == (media.likes_count <= count))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 17
0
def test_get_media_account_pointer(count, username):
    anon = Agent()
    account = Account(username)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = anon.get_media(account, pointer=pointer)
        data.extend(tmp)

    assert ((pointer is None) == (account.media_count <= count))

    Account.clear_cache()
    Media.clear_cache()
Exemplo n.º 18
0
def test_get_media_location_pointer(login, password, count, id):
    agent = AgentAccount(login, password)
    location = Location(id)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = agent.get_media(location, pointer=pointer)
        data.extend(tmp)

    assert ((pointer is None) == (location.media_count <= count))

    Account.clear_cache()
    Media.clear_cache()
    Location.clear_cache()
Exemplo n.º 19
0
def test_get_media_tag_pointer(login, password, count, name):
    agent = AgentAccount(login, password)
    tag = Tag(name)
    pointer = None
    data = []

    for i in range(count):
        tmp, pointer = agent.get_media(tag, pointer=pointer)
        data.extend(tmp)

    assert ((pointer is None) == (tag.media_count <= count))

    Account.clear_cache()
    Media.clear_cache()
    Tag.clear_cache()
Exemplo n.º 20
0
def test_update_account(username):
    anon = Agent()
    account = Account(username)

    data = anon.update(account)

    assert (not data is None)
    assert (not account.id is None)
    assert (not account.full_name is None)
    assert (not account.profile_pic_url is None)
    assert (not account.profile_pic_url_hd is None)
    assert (not account.biography is None)
    assert (not account.follows_count is None)
    assert (not account.followers_count is None)
    assert (not account.media_count is None)
    assert (not account.is_private is None)
    assert (not account.is_verified is None)
    assert (not account.country_block is None)

    Account.clear_cache()
Exemplo n.º 21
0
def test_clear_cache_account():
    account = Account("test")
    
    Account.clear_cache()
    
    assert(Account._cache == dict())
Exemplo n.º 22
0
def test_clear_cache_account(id):
    account = Account(id)
    assert Account.cache == {id: account}

    Account.clear_cache()
    assert Account.cache == dict()
Exemplo n.º 23
0
def test_auth(login, password):
    agent = AgentAccount(login, password)

    Account.clear_cache()