class MessagesApi(BaseApi): def __init__(self, token): super(MessagesApi, self).__init__() self.token = token self.logger = MyLogger() def send(self, user_model, text): """ Отправляет сообщение. После успешного выполнения возвращает идентификатор отправленного сообщения. """ url = '{api}messages.send'.format(api=self.api_url) params = { 'user_id': user_model.user_id, 'access_token': self.token, 'message': '{first_name}, {message}'.format(first_name=user_model.first_name, message=text), 'v': self.api_version } res = HttpLib(url=url, params=params).send_get() status_code = res.response.status_code assert status_code == status_code_200, '"Messages.send" FAILED. {text}'.format( text=res.response.text) self.logger.log_info( ' Сообщение отправлено. Пользователь: id{user_id}, {first_name} {last_name}.' .format(user_id=user_model.user_id, first_name=user_model.first_name, last_name=user_model.last_name)) return get_value_from_json(res.response.json(), 'response')
def __init__(self, url, header=None, params=None, cookie=None, body=None, json=None, auth=None, response=None): self.url = url self.header = header self.params = params self.cookie = cookie self.body = body self.json = json self.auth = auth self.response = response self.logger = MyLogger()
from project.steps.messagesSteps import send_birthday_messages_sto325 from project.steps.usersSteps import search_birthday_users from timeit import default_timer as timer from framework.support.MyLogger import MyLogger numbers_tokens = [ [ "29 6235325", "eed19b302144ead88c4e7c798689033343374bbbefc3c58986bf695642895a3ee1d1d37d35d88e451cf3d", get_random_int(10, 15) ], # ["29 5375325", "95db3f151cf1e653017054624402b9c3390a936b3e0444317ec13ed8b5a8897fefb4baf4d3040d1170ba0", get_random_int(10, 15)], # ["25 7175325", "1d5ad974a8c4ae0b4d1ee4ce28f342fdb2549d5b2bbcfda670ba6b9a73e69c37c767c6ca27280a8f90a1d", get_random_int(10, 15)] ] logger = MyLogger() def run_sender(age_from, age_to): start = timer() # sec = get_random_int(60, 1000) # logger.log_info('Задержка: {min}min {sec}s.'.format(min=sec//60, sec=sec % 60)) # sleep(sec) offset = 0 count = 0 status = 'PASS' message = '' try: for item in numbers_tokens: logger.log_step(item[0]) logger.log_info('Смещение: {offset}.'.format(offset=offset))
def __init__(self, token): super(MessagesApi, self).__init__() self.token = token self.logger = MyLogger()
def __init__(self): self.api_url = api_url self.api_version = api_version self.logger = MyLogger()