def test_edit_section_with_name_outsider(self):
     team_uid = func.add_team(self.api)['uid']
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     new_name = 'edit_' + tools.generate_random_string()
     data = {'name': new_name}
     api4 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api4.edit_section(team_uid, section_uid, data).json()
     assert resp['error'] == const.ACCESS_DENIED
 def test_edit_section_with_name(self):
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(self.team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     new_name = 'edit_' + tools.generate_random_string()
     data = {'name': new_name}
     resp = self.api.edit_section(self.team_uid, section_uid, data).json()
     assert 'error' not in resp
     assert resp['result']['uid'] == section_uid
     assert resp['result']['name'] == new_name
 def test_edit_section_with_name_admin(self):
     team_uid = func.add_team(self.api)['uid']
     func.add_contact(self.api, team_uid, self.phone2, 'admin')
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     new_name = 'edit_' + tools.generate_random_string()
     data = {'name': new_name}
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.edit_section(team_uid, section_uid, data).json()
     assert 'error' not in resp
     assert resp['result']['uid'] == section_uid
     assert resp['result']['name'] == new_name
Beispiel #4
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
Beispiel #5
0
 def test_add_team_with_name_100_symbols(self):
     name = tools.generate_random_string(101)
     data = {'name': name}
     resp = self.api.add_team(data)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['name'] == name
Beispiel #6
0
 def test_add_team_with_name_101_symbols(self):
     data = {'name': tools.generate_random_string(102)}
     resp = self.api.add_team(data)
     resp = resp.json()
     assert const.INVALID_DATA == resp['error']
     assert 'Убедитесь, что это значение содержит не более 100 символов (сейчас 101).' == resp[
         'details']['name']
Beispiel #7
0
 def test_add_team_with_name_start_with(self, first_symbol):
     name = first_symbol + tools.generate_random_string(30)
     data = {'name': name}
     resp = self.api.add_team(data)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['name'] == name
Beispiel #8
0
 def test_get_messages_chat(self):
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     group_jid_2 = func.add_group(self.api, self.team_uid)['jid']
     group_jid_3 = func.add_group(self.api, self.team_uid)['jid']
     # добавляем сообщения
     text = 'msg_{}'.format(tools.generate_random_string(7))
     func.send_text(self.api, self.team_uid, group_jid, text)
     func.send_text(self.api, self.team_uid, group_jid_2, text)
     func.send_text(self.api, self.team_uid, group_jid_3, text)
     params = {
         'chat': f'{group_jid},{group_jid_2}',
     }
     resp = self.api.get_filtered_messages(self.team_uid, params).json()
     assert 'error' not in resp
     assert tools.is_items_exist_in_list_of_dict(
         resp['result']['objects'],
         'chat',
         group_jid,
     )
     assert tools.is_items_exist_in_list_of_dict(
         resp['result']['objects'],
         'chat',
         group_jid_2,
     )
     assert not tools.is_items_exist_in_list_of_dict(
         resp['result']['objects'],
         'chat',
         group_jid_3,
     )
Beispiel #9
0
def add_section(api_obj, team_uid, name=''):
    """ Функция для быстрого добавления секции """
    data = {'name': name}
    if not name:
        data['name'] = 'section_' + tools.generate_random_string(10)
    resp = api_obj.add_section(team_uid, data).json()
    return {'name': resp['result']['name'], 'uid': resp['result']['uid']}
 def test_add_section_with_name_one_symbol(self):
     name = tools.generate_random_string(2)
     data = {'name': name}
     resp = self.api.add_section(self.team_uid, data)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['name'] == name
 def test_delete_section_outsider(self):
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(self.team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api2.delete_section(self.team_uid, section_uid).json()
     assert resp['error'] == const.ACCESS_DENIED
Beispiel #12
0
 def test_send_text_8000_symbols(self):
     # создаем группу
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     data = {'text': tools.generate_random_string(8001)}
     resp = self.api.send_msg_text(self.team_uid, group_jid, data).json()
     assert 'error' not in resp['result']
     assert resp['result']['content']['text'] == data['text']
Beispiel #13
0
 def test_send_text_8001_symbols(self):
     # создаем группу
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     data = {'text': tools.generate_random_string(8002)}
     resp = self.api.send_msg_text(self.team_uid, group_jid, data).json()
     assert resp['error'] == const.INVALID_DATA
     assert resp['details']['text'] == 'Ошибка отправки'
 def test_edit_section_with_empty_name(self):
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(self.team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     data = {'name': ''}
     resp = self.api.edit_section(self.team_uid, section_uid, data).json()
     assert resp['error'] == const.INVALID_DATA
     assert 'Обязательное поле.' == resp['details']['name']
 def test_edit_section_without_param(self):
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(self.team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     data = {}
     resp = self.api.edit_section(self.team_uid, section_uid, data).json()
     assert 'error' not in resp
     assert resp['result'] == exp_dict['result']
Beispiel #16
0
 def test_add_subscriber_email_invalid(self):
     email = tools.generate_random_string()
     data = {'email': email, 'name': 'Ivan', 'time': '7d'}
     data = json.dumps(data)
     resp = self.api.add_subscriber(data)
     assert resp.status_code == STATUS_OK
     assert resp.json(
     )['error'] == f"ValidationError (SubscriptionModel:None) (Invalid email address: {email}: ['email'])"
 def test_delete_exist_section_member(self):
     team_uid = func.add_team(self.api)['uid']
     func.add_contact(self.api, team_uid, self.phone2, 'member')
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     resp = api2.delete_section(team_uid, section_uid).json()
     assert resp['error'] == const.ACCESS_DENIED
Beispiel #18
0
 def test_get_messages_exact(self):
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     text = tools.generate_random_string(7)
     message_id = func.send_text(self.api, self.team_uid, group_jid, text)['message_id']
     params = {'exact': message_id}
     resp = self.api.get_messages(self.team_uid, group_jid, params).json()
     assert 'error' not in resp['result']
     assert len(resp['result']['messages']) == 1
     assert resp['result']['messages'][0]['content']['text'] == text
Beispiel #19
0
def add_tasklist(api_obj, team_uid, name=''):
    """ Функция для быстрого добавления тасклиста """
    data = {'name': name}
    if not name:
        data['name'] = 'tasklist_' + tools.generate_random_string(10)
    resp = api_obj.add_tasklist(team_uid, data).json()
    for el in resp['result']:
        if el['name'] == data['name']:
            return {'name': el['name'], 'uid': el['uid']}
Beispiel #20
0
 def test_edit_team_name_outsider(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     new_name = 'new_' + tools.generate_random_string()
     data = {'name': new_name}
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api2.edit_team(team_uid, data)
     resp = resp.json()
     assert resp['error'] == const.ACCESS_DENIED
Beispiel #21
0
 def test_edit_team_name_member(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     func.add_contact(self.api, team_uid, self.phone2, role='member')
     new_name = 'new_' + tools.generate_random_string()
     data = {'name': new_name}
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.edit_team(team_uid, data).json()
     assert resp['error'] == const.ACCESS_DENIED
Beispiel #22
0
 def test_add_team_invite_user_without_firstname_and_lastname(self):
     name = tools.generate_random_string()
     phone = self.config['users']['user2']['phone']
     data = {'name': name, 'contacts': [{'phone': phone}]}
     data_json = json.dumps(data)
     resp = self.api.add_team(data_json).json()
     assert 'error' not in resp
     assert resp['result']['name'] == name
     assert resp['result']['contacts'][0]['contact_phone'] == phone
Beispiel #23
0
def send_text(api_obj, team_uid, group_jid, text=''):
    """ Функция для быстрой отправки текстового сообщения """
    if not text:
        text = 'msg_' + tools.generate_random_string()
    msg_data = {'text': text}
    resp = api_obj.send_msg_text(team_uid, group_jid, msg_data).json()
    return {
        'text': resp['result']['content']['text'],
        'message_id': resp['result']['message_id']
    }
 def test_delete_exist_section(self):
     data = {'name': tools.generate_random_string()}
     exp_dict = self.api.add_section(self.team_uid, data).json()
     section_uid = exp_dict['result']['uid']
     resp = self.api.delete_section(self.team_uid, section_uid).json()
     resp2 = self.api.get_sections(self.team_uid).json()
     assert 'error' not in resp
     assert resp['result'] is None
     for item in resp2['result']:
         assert section_uid != item['uid']
Beispiel #25
0
def add_group(api_obj, team_uid, name='', public=False):
    """ Функция для быстрого добавления группы """
    if not name:
        name = 'group_' + tools.generate_random_string(10)
    data = {'display_name': name, 'public': public}
    resp = api_obj.add_group(team_uid, data).json()
    return {
        'display_name': resp['result']['display_name'],
        'jid': resp['result']['jid']
    }
Beispiel #26
0
 def test_edit_team_name_valid(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     new_name = 'new_' + tools.generate_random_string()
     data = {'name': new_name}
     resp = self.api.edit_team(team_uid, data)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['uid'] == team_uid
     assert resp['result']['name'] == new_name
Beispiel #27
0
def add_task(api_obj, team_uid, title='', description='', tasklist=''):
    """ Функция для быстрого создания задачи """
    if not title:
        title = 'title_' + tools.generate_random_string(10)
    if not description:
        description = 'desc_' + tools.generate_random_string(10)
    data = {
        'title': title,
        'description': description,
    }
    if tasklist:
        data['tasklist'] = tasklist
    resp = api_obj.add_task(team_uid, data).json()['result']
    return {
        'uid': resp['uid'],
        'title': resp['title'],
        'tasklist': resp['tasklist'],
        'description': resp['description']
    }
Beispiel #28
0
def add_team(api_obj, name=''):
    """ Функция для быстрого добавления команды """
    data = {'name': name}
    if not name:
        data['name'] = 'team_' + tools.generate_random_string()
    resp = api_obj.add_team(data).json()
    return {
        'name': resp['result']['name'],
        'uid': resp['result']['uid'],
        'owner_jid': resp['result']['contacts'][0]['jid']
    }
Beispiel #29
0
 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
Beispiel #30
0
 def test_get_messages_limit(self):
     group_jid = func.add_group(self.api, self.team_uid)['jid']
     # добавляем сообщения в цикле
     for i in range(5):
         text = 'msg_{}_{}'.format(tools.generate_random_string(7), i)
         func.send_text(self.api, self.team_uid, group_jid, text)
     limit = 3
     params = {'limit': limit}
     resp = self.api.get_messages(self.team_uid, group_jid, params).json()
     assert 'error' not in resp['result']
     assert len(resp['result']['messages']) == limit