Example #1
0
def setup_function():
    Account.clear_cache()
    Comment.clear_cache()
    Location.clear_cache()
    Media.clear_cache()
    Story.clear_cache()
    Tag.clear_cache()
Example #2
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)
Example #3
0
    def sortPeoples(self, startSort=0):
        agent = WebAgent()
        if startSort == 0:
            scaningPeoples = self.scaningPeoples
        else:
            scaningPeoples = self.scaningPeoples[startSort:]

        for people in scaningPeoples:
            try:
                account = Account(people)
                agent.update(account)
                biography = account.biography
                name = account.full_name
                infoAcc = biography + name
                print(people)
                if self.sortByTown(infoAcc.lower()) and self.sortByActivity(
                        infoAcc.lower()):
                    self.sortingPeoples.append(people)
                self.currentSortPeople += 1
            except:
                print('errorSort')
                self.offVpn()
                self.onVpn()
                self.playSortPeoples()
        return self.sortingPeoples
Example #4
0
def test_get_media_account(agent, delay, settings, count, username):
    account = Account(username)
    data, pointer = agent.get_media(account,
                                    count=count,
                                    delay=delay,
                                    settings=settings)

    assert min(account.media_count, count) == len(data)
    assert (pointer is None) == (account.media_count <= count)
Example #5
0
async def test_async_get_media_account_pointer(async_agent, delay, settings, count, username):
    account = Account(username)
    pointer = None
    data = []

    for _ in range(count):
        tmp, pointer = await async_agent.get_media(account, pointer=pointer, settings=settings)
        await asyncio.sleep(delay)
        data.extend(tmp)

    assert (pointer is None) == (account.media_count == len(data))
Example #6
0
def test_get_followers(agent_account, delay, settings, count, username):
    account = Account(username)
    data, pointer = agent_account.get_followers(
        account,
        count=count,
        delay=delay,
        settings=settings,
    )

    assert min(account.followers_count, count) == len(data)
    assert (pointer is None) == (account.followers_count <= count)
Example #7
0
def test_follow_unfollow(agent_account, delay, settings, username):
    account = Account(username)
    agent_account.update(settings=settings)
    follows_count = agent_account.follows_count

    assert agent_account.follow(account, settings=settings)
    sleep(delay)
    agent_account.update(settings=settings)
    assert agent_account.follows_count == follows_count + 1
    assert agent_account.unfollow(account, settings=settings)
    sleep(delay)
    agent_account.update(settings=settings)
    assert agent_account.follows_count == follows_count
Example #8
0
def test_get_follows_pointer(agent_account, delay, settings, count, username):
    account = Account(username)
    pointer = None
    data = []

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

    assert (pointer is None) == (account.follows_count <= count)
Example #9
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}
Example #10
0
async def test_async_follow_unfollow(async_agent_account, delay, settings,
                                     username):
    account = Account(username)
    await async_agent_account.update(settings=settings)
    follows_count = async_agent_account.follows_count

    assert await async_agent_account.follow(account, settings=settings)
    await asyncio.sleep(delay)
    await async_agent_account.update(settings=settings)
    assert async_agent_account.follows_count == follows_count + 1
    assert await async_agent_account.unfollow(account, settings=settings)
    await asyncio.sleep(delay)
    await async_agent_account.update(settings=settings)
    assert async_agent_account.follows_count == follows_count
Example #11
0
async def test_async_update_account(async_agent, settings, username):
    account = Account(username)
    data = await async_agent.update(account, settings=settings)

    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
Example #12
0
    def scanPeoples(self, entry):
        agent = WebAgentAccount(self.agent)
        agent.auth(self.password)
        account = Account(entry)
        agent.update(account)

        if self.getFollowers:
            followersCount = account.followers_count
            followsCount = account.follows_count

            follows = agent.get_follows(account, None, followsCount)[0]
            followers = agent.get_followers(account, None, followersCount)[0]

            self.scaningPeoples += follows + followers
            return
        else:
            followsCount = account.follows_count
            follows = agent.get_follows(account, None, followsCount)[0]

            self.scaningPeoples += follows
            return
Example #13
0
def test_clear_cache_account(id):
    account = Account(id)
    assert Account.cache == {id: account}

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