Пример #1
0
 def setup_class(self):
     # Логин и создание команды, далее эта команда используется в тестах
     self.url = self.config['api']['url']
     phone = self.user['phone']
     code = self.user['code']
     auth_cookies = auth.login_with_cookies(self.url, phone, code)
     self.api = API(self.url, auth_cookies, is_token_auth=False)
     resp = func.add_team(self.api)
     self.team_uid = resp['uid']
Пример #2
0
    def setup_class(self):
        self.api = API(self.api_url)
        self.driver = config_and_run_browser(self.config)

        # для запуска локального браузера
        #self.driver = webdriver.Chrome(executable_path="/Users/arkuz/Repos/subscribe_tests/chromedriver")
        #self.driver.maximize_window()

        self.driver.get(self.url)
        self.main_page = MainPage(self.driver)
Пример #3
0
 def test_send_text_readonly_for_members_true(self):
     # создаем группу с readonly_for_members: true
     data = {'display_name': tools.generate_random_string(),
             'public': False,
             'readonly_for_members': True}
     resp = self.api.add_group(self.team_uid, data).json()
     group_jid = resp['result']['jid']
     # добавляем участника в команду и в группу
     user2_jid = func.add_contact(self.api, self.team_uid, self.phone2)['jid']
     func.add_member_to_group(self.api, self.team_uid, group_jid, user2_jid, 'member')
     auth_cookies = auth.login_with_cookies(self.url, self.phone2, self.code2)
     api2 = API(self.url, auth_cookies, is_token_auth=False)
     msg_data = {'text': tools.generate_random_string()}
     resp = api2.send_msg_text(self.team_uid, group_jid, msg_data).json()
     assert resp['error'] == const.ACCESS_DENIED
Пример #4
0
 def test_get_messages_unread(self):
     user2_jid = func.add_contact(self.api, self.team_uid, self.phone2)['jid']
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     func.add_member_to_group(self.api, self.team_uid, group_jid, user2_jid, 'admin')
     # добавляем сообщения в цикле
     exp_msg = {}
     for i in range(5):
         # эта магия с i для того, чтобы ключи словаря exp_msg совпадали с ключами в resp т.к. в ответе есть всегда 2 дефолтных сообщения
         i = i + 1
         text = 'msg_{}_{}'.format(tools.generate_random_string(7), i)
         exp_msg[i] = text
         func.send_text(self.api, self.team_uid, group_jid, text)
     auth_cookies = auth.login_with_cookies(self.url, self.phone2, self.code2)
     api2 = API(self.url, auth_cookies, is_token_auth=False)
     params = {'unread': True}
     resp = api2.get_messages(self.team_uid, group_jid, params).json()
     assert 'error' not in resp['result']
     assert len(resp['result']['messages']) == 6
     num = 5
     while num > 0:
         assert resp['result']['messages'][num]['content']['text'] == exp_msg[num]
         num = num - 1
Пример #5
0
def main():
    model = Model(model_file='models/Model.h5',
                  scaler_file='models/scaler.pkl')
    api = API()

    companies = pd.read_json('models/companies.json')

    for company in companies.loc[:, 'Symbol']:
        prediction = model.predict_tomorrow(company)

        stock = StockCollection(company)
        high, low, open_price, close_price, volume = stock.get_yesterday_data()

        update_response = api.update_previous_day(company, high, low,
                                                  open_price, close_price,
                                                  volume)
        create_response = api.submit_prediction(company, prediction)

        print(
            f'Stock: {company} Update reponse: {update_response.status_code} Create response: {create_response.status_code}'
        )

    return
Пример #6
0
 def setup_method(self):
     self.url = self.config['api']['url']
     phone = self.user['phone']
     code = self.user['code']
     auth_cookies = auth.login_with_cookies(self.url, phone, code)
     self.api = API(self.url, auth_cookies, is_token_auth=False)
Пример #7
0
from flask import Flask, url_for, request, redirect, render_template

from helpers.secrets import Secrets
from helpers.api import API
from helpers.file_saver import FileSaver


# Read the config file
config = configparser.ConfigParser()
config.read('config/config.ini')

# Initialize secret files
secrets = Secrets(file_path=config['Secrets']['file_path'])

# Initialize API helper
api = API(consumer_key=config['OAuth']['consumer_key'], consumer_secret=config['OAuth']['consumer_secret'])

# If we already have user tokens, we initialize the API with it
if secrets.has_section('OAuth'):
    api.set_oauth_token(oauth_token=secrets.get('OAuth', 'oauth_token'),
                        oauth_token_secret=secrets.get('OAuth', 'oauth_token_secret'))

# Build the flask application
app = Flask(__name__)


@app.route('/login')
def login():
    """
    Login on 500px to authorize the application
    """
Пример #8
0
import json
import os
import pytest

import helpers.const as const
from helpers.api import API
from helpers.readers import read_yaml
from helpers.tools import generate_random_string, generate_email


config = read_yaml(os.path.join(const.PROJECT, 'config.yaml'))
api_url = config['api_url']
api = API(api_url)


@pytest.fixture
def add_subscriber_fixture():
    def _method(count=1):
        result_list = []
        for i in range(0, count):
            data = {
                'email': generate_email(),
                'name': generate_random_string(),
                'time': '7d',
            }
            api.add_subscriber(json.dumps(data))
            result_list.append(data)
        return result_list
    return _method

Пример #9
0
def login_another_user(url, phone, code):
    auth_cookies = login_with_cookies(url, phone, code)
    return API(url, auth_cookies, is_token_auth=False)
Пример #10
0
 def setup_class(self):
     self.api = API(self.api_url)
Пример #11
0
def login_user(config, user_number):
    phone = config['users'][f'user{user_number}']['phone']
    code = config['users'][f'user{user_number}']['code']
    auth_cookies = auth.login_with_cookies(url, phone, code)
    return API(url, auth_cookies, is_token_auth=False), phone