示例#1
0
def setup_function():
    Account.clear_cache()
    Comment.clear_cache()
    Location.clear_cache()
    Media.clear_cache()
    Story.clear_cache()
    Tag.clear_cache()
示例#2
0
def test_update_photo_set(shortcode):
    anon = Agent()
    photo_set = Media(shortcode)

    data = anon.update(photo_set)

    assert (not photo_set.is_video)

    Media.clear_cache()
示例#3
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()
示例#4
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()
示例#5
0
def test_update_photo_set(login, password, shortcode):
    agent = AgentAccount(login, password)
    photo_set = Media(shortcode)

    data = agent.update(photo_set)

    assert (not photo_set.is_video)

    Media.clear_cache()
示例#6
0
def test_update_video(login, password, shortcode):
    agent = AgentAccount(login, password)
    video = Media(shortcode)

    data = agent.update(video)

    assert (video.is_video)

    Media.clear_cache()
示例#7
0
def test_get_likes(shortcode):
    anon = Agent()
    media = Media(shortcode)

    data, pointer = anon.get_likes(media)

    assert (media.likes_count >= len(data))

    Media.clear_cache()
示例#8
0
def test_update_video(shortcode):
    anon = Agent()
    video = Media(shortcode)

    data = anon.update(video)

    assert (video.is_video)

    Media.clear_cache()
示例#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)
示例#10
0
def test_get_comments_long(count, shortcode):
    anon = Agent()
    media = Media(shortcode)

    data, pointer = anon.get_comments(media, count=count)

    assert (min(media.comments_count, count) == len(data))
    assert ((pointer is None) == (media.likes_count <= count))

    Media.clear_cache()
示例#11
0
def test_get_likes_long(login, password, count, shortcode):
    agent = AgentAccount(login, password)
    media = Media(shortcode)

    data, pointer = agent.get_likes(media, count=count)

    assert (min(media.likes_count, count) == len(data))
    assert ((pointer is None) == (media.likes_count <= count))

    Media.clear_cache()
示例#12
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()
示例#13
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()
示例#14
0
def test_get_media_tag_long(login, password, count, name):
    agent = AgentAccount(login, password)
    tag = Tag(name)

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

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

    Tag.clear_cache()
    Media.clear_cache()
示例#15
0
def test_clear_cache_comment():
    account = Account("test")
    media = Media("test")
    comment = Comment(1488, media=media, owner=account, text="test",
                      created_at=0)
    
    Media.clear_cache()
    Comment.clear_cache()
    
    assert(Comment._cache == dict())
    assert(Media._cache == dict())
示例#16
0
def test_get_media_account_long(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()
示例#17
0
def test_get_media_location_long(login, password, count, id):
    agent = AgentAccount(login, password)
    location = Location(id)

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

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

    Location.clear_cache()
    Media.clear_cache()
示例#18
0
def test_get_media_location_long(count, id):
    anon = Agent()
    location = Location(id)

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

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

    Location.clear_cache()
    Media.clear_cache()
示例#19
0
def test_get_media_tag_long(count, name):
    anon = Agent()
    tag = Tag(name)

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

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

    Tag.clear_cache()
    Media.clear_cache()
示例#20
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()
示例#21
0
def test_get_comments_pointer(count, shortcode):
    anon = Agent()
    media = Media(shortcode)
    pointer = None
    data = []

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

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

    Media.clear_cache()
示例#22
0
def test_get_media_location_pointer(count, id):
    anon = Agent()
    location = Location(id)
    pointer = None
    data = []

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

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

    Location.clear_cache()
    Media.clear_cache()
示例#23
0
def test_get_media_account_pointer(login, password, count, username):
    agent = AgentAccount(login, password)
    account = Account(username)
    pointer = None
    data = []

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

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

    Account.clear_cache()
    Media.clear_cache()
示例#24
0
def test_get_media_tag_pointer(count, name):
    anon = Agent()
    tag = Tag(name)
    pointer = None
    data = []

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

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

    Tag.clear_cache()
    Media.clear_cache()
示例#25
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()
示例#26
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()
示例#27
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()
示例#28
0
def test_clear_cache_media():
    media = Media("test")
    
    Media.clear_cache()
    
    assert(Media._cache == dict())
示例#29
0
def test_clear_cache_media(id):
    media = Media(id)
    assert Media.cache == {id: media}

    Media.clear_cache()    
    assert Media.cache == dict()