def setup_function():
    Account.clear_cache()
    Comment.clear_cache()
    Location.clear_cache()
    Media.clear_cache()
    Story.clear_cache()
    Tag.clear_cache()
Beispiel #2
0
def test_update_location(login, password, id):
    agent = AgentAccount(login, password)
    location = Location(id)

    data = agent.update(location)

    Location.clear_cache()
Beispiel #3
0
def test_update_location(id):
    anon = Agent()
    location = Location(id)

    data = anon.update(location)

    Location.clear_cache()
Beispiel #4
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)
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
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()
Beispiel #8
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()
Beispiel #9
0
def test_get_media_location(agent, delay, settings, count, id):
    location = Location(id)
    data, pointer = agent.get_media(location,
                                    count=count,
                                    delay=delay,
                                    settings=settings)

    assert min(location.media_count, count) == len(data)
    assert (pointer is None) == (location.media_count <= count)
Beispiel #10
0
async def test_async_update_location(async_agent, settings, id):
    location = Location(id)
    data = await async_agent.update(location, settings=settings)

    assert not data is None
    assert not location.id is None
    assert not location.slug is None
    assert not location.name is None
    assert not location.has_public_page is None
    assert not location.coordinates is None
    assert not location.media_count is None
Beispiel #11
0
def test_get_media_location_pointer(agent_account, delay, settings, count, id):
    location = Location(id)
    pointer = None
    data = []

    for _ in range(count):
        tmp, pointer = agent_account.get_media(location, pointer=pointer, settings=settings)
        sleep(delay)
        data.extend(tmp)

    assert (pointer is None) == (location.media_count == len(data))
Beispiel #12
0
def test_clear_cache_location():
    location = Location(1488)
    
    Location.clear_cache()
    
    assert(Location._cache == dict())
Beispiel #13
0
def test_clear_cache_location(id):
    location = Location(id)
    assert Location.cache == {id: location}

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