Пример #1
0
def test_update_tag(login, password, name):
    agent = AgentAccount(login, password)
    tag = Tag(name)

    data = agent.update(tag)

    Tag.clear_cache()
Пример #2
0
def test_get_stories(login, password):
    agent = AgentAccount(login, password)

    data = agent.stories()

    Account.clear_cache()
    Story.clear_cache()
Пример #3
0
def test_update_location(login, password, id):
    agent = AgentAccount(login, password)
    location = Location(id)

    data = agent.update(location)

    Location.clear_cache()
Пример #4
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()
Пример #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()
Пример #6
0
def test_update(login, password):
    agent = AgentAccount(login, password)

    agent.update()

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

    Account.clear_cache()
Пример #7
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()
Пример #8
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()
Пример #9
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()
Пример #10
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()
Пример #11
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()
Пример #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_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()
Пример #14
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()
Пример #15
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()
Пример #16
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()
Пример #17
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()
Пример #18
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()
Пример #19
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()
Пример #20
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()
Пример #21
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()
Пример #22
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()
Пример #23
0
def test_auth(login, password):
    agent = AgentAccount(login, password)

    Account.clear_cache()
Пример #24
0
def agent_account(settings):
    return AgentAccount(creds["login"], creds["password"], settings=settings)
Пример #25
0
from flask import Flask, send_file, send_from_directory
from instaparser.agents import AgentAccount
import json
import os

app = Flask(__name__)
TOTAL = None
username = os.environ.get('INSTAGRAM_USERNAME')
password = os.environ.get('INSTAGRAM_PASSWORD')
account = AgentAccount(username, password)
file_path = os.environ.get("FILE_PATH")
file_name = os.environ.get("FILE_NAME")


def getFollowers():
    global TOTAL
    account.update(account)

    amt_of_followers = account.followers_count
    foll_dict = dict()
    foll_dict['profile'] = username
    foll_dict['number'] = amt_of_followers

    if TOTAL is None:
        TOTAL = amt_of_followers
    else:
        if amt_of_followers > TOTAL:
            diff = amt_of_followers - TOTAL
            get_new_followers = account.get_followers(account=account,
                                                      count=diff)
            new_followers = [str(item) for item in get_new_followers[0]]
Пример #26
0
from instaparser.agents import AgentAccount
from instaparser.entities import Media


agent = AgentAccount("vasiliyvasilenko8", "?naScar88")


def check_likes(username, media):
    media = Media(media)
    pointer = 0
    while not pointer is None:
        likes, pointer = agent.get_likes(media, pointer=pointer)
        for like in likes:
                if str(like) == username:
                    return True
    return False