Exemplo n.º 1
0
 def test_edit_contact_with_empty_data(self):
     team_uid = func.add_team(self.api)['uid']
     data = {'phone': self.phone2}
     self.api.add_contacts(team_uid, data)
     resp = self.api.get_contacts(team_uid).json()
     contact_jid = resp['result'][0]['jid']
     act_data = {
         'family_name': resp['result'][0]['family_name'],
         'given_name': resp['result'][0]['given_name'],
         'contact_phone': resp['result'][0]['contact_phone'],
         'role': resp['result'][0]['role'],
         'status': resp['result'][0]['status'],
         'contact_email': resp['result'][0]['contact_email']
     }
     data = {}
     res = self.api.edit_contact(team_uid, contact_jid, data).json()
     resp = res['result']
     exp_data = {
         'family_name': resp['family_name'],
         'given_name': resp['given_name'],
         'contact_phone': resp['contact_phone'],
         'role': resp['role'],
         'status': resp['status'],
         'contact_email': resp['contact_email']
     }
     assert 'error' not in res
     assert act_data == exp_data
Exemplo n.º 2
0
 def test_get_contact_outsider(self):
     team_uid = func.add_team(self.api)['uid']
     resp = self.api.get_contacts(team_uid).json()
     contact_jid = resp['result'][0]['jid']
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.get_contact(team_uid, contact_jid).json()
     assert const.ACCESS_DENIED == resp['error']
Exemplo n.º 3
0
 def test_invite_one_contact_all_params(self):
     team_uid = func.add_team(self.api)['uid']
     section_uid = func.add_section(self.api, team_uid)['uid']
     data = {
         'family_name': 'Фамилия',
         'given_name': 'Имя',
         'phone': self.phone2,
         'role': 'пресс-секретарь',
         'section': section_uid,
         'status': 'admin'
     }
     resp = self.api.add_contacts(team_uid, data).json()
     resp2 = self.api.get_contacts(team_uid).json()
     resp2 = resp2['result'][0]
     exp_data = {
         'family_name': resp2['family_name'],
         'given_name': resp2['given_name'],
         'phone': resp2['contact_phone'],
         'role': resp2['role'],
         'section': resp2['section_uid'],
         'status': resp2['status']
     }
     assert 'error' not in resp
     assert self.phone2 == resp['result']['contact_phone']
     assert exp_data == data
Exemplo n.º 4
0
 def test_upload_team_icon_outsider(self):
     resp = func.add_team(self.api)
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api2.upload_team_icon(resp['uid'],
                                  os.path.join(const.TD_FILES, 'tiger.jpg'))
     resp = resp.json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 5
0
 def test_invite_one_contact_empty(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     data = {}
     resp = self.api.add_contacts(team_uid, data).json()
     assert resp['error'] == const.INVALID_DATA
     assert 'Обязательное поле.' == resp['details']['phone']
Exemplo n.º 6
0
 def test_get_team_valid_uid_outsider(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api2.delete_team(team_uid)
     resp = resp.json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 7
0
 def test_edit_contact_valid(self):
     team_uid = func.add_team(self.api)['uid']
     data = {'phone': self.phone2}
     self.api.add_contacts(team_uid, data)
     resp = self.api.get_contacts(team_uid).json()
     contact_jid = resp['result'][0]['jid']
     data = {
         'family_name': 'Brown',
         'given_name': 'Jack',
         'contact_phone': '+70000000000',
         'role': 'Secret Agent',
         'status': 'admin',
         'contact_email': '*****@*****.**'
     }
     res = self.api.edit_contact(team_uid, contact_jid, data).json()
     resp = res['result']
     exp_data = {
         'family_name': resp['family_name'],
         'given_name': resp['given_name'],
         'contact_phone': resp['contact_phone'],
         'role': resp['role'],
         'status': resp['status'],
         'contact_email': resp['contact_email']
     }
     assert 'error' not in res
     assert data == exp_data
Exemplo n.º 8
0
 def test_delete_contact_icon_another_user(self):
     team_uid = func.add_team(self.api)['uid']
     resp = self.api.get_contacts(team_uid).json()
     contact_jid = resp['result'][0]['jid']
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api2.delete_contact_icon(self.team_uid, contact_jid)
     resp = resp.json()
     assert const.ACCESS_DENIED == resp['error']
Exemplo n.º 9
0
 def test_invite_contact_outsider(self):
     team_uid = func.add_team(self.api)['uid']
     data = {'phone': self.phone2, 'status': 'member'}
     self.api.add_contacts(team_uid, data)
     api2 = auth.login_another_user(self.url, self.phone4, self.code4)
     data = {'phone': self.phone3}
     resp = api2.add_contacts(team_uid, data).json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 10
0
 def test_invite_one_contact_section_invalid(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     data = {"phone": self.phone2, "section": self.invalid_section_uid}
     resp = self.api.add_contacts(team_uid, data).json()
     assert resp['error'] == const.INVALID_DATA
     assert "Некорректная секция: '{uid}'".format(
         uid=self.invalid_section_uid) == resp['details']['section']
Exemplo n.º 11
0
 def test_upload_team_icon_invalid(self, filename):
     resp = func.add_team(self.api)
     resp = self.api.upload_team_icon(
         resp['uid'], os.path.join(const.TD_FILES, filename))
     resp = resp.json()
     assert const.INVALID_DATA == resp['error']
     assert 'Ошибка при загрузке. Пожалуйста, попробуйте ещё раз' == resp[
         'details']['file']
Exemplo n.º 12
0
 def test_get_botcommands_admin(self):
     team_uid = func.add_team(self.api)['uid']
     group_jid = func.add_group(self.api, team_uid)['jid']
     resp = self.api.get_botcommands(team_uid, group_jid).json()
     path = os.path.join(const.EXPECTED_RESULTS, 'bot_commands_admin.json')
     expected = read_json(path)
     assert 'error' not in resp
     assert resp['result'] == expected['result']
Exemplo n.º 13
0
 def test_send_help(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     email = '*****@*****.**'
     text = 'I need help'
     resp = self.api.send_help(team_uid, email, text).json()
     assert 'error' not in resp
     assert resp['result'] == 'OK'
Exemplo n.º 14
0
 def test_edit_team_name_empty(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     data = {'name': ''}
     resp = self.api.edit_team(team_uid, data)
     resp = resp.json()
     assert resp['error'] == const.INVALID_DATA
     assert resp['details']['name'] == 'Обязательное поле.'
Exemplo n.º 15
0
 def test_send_help_outsider(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     email = '*****@*****.**'
     text = 'I need help, outsider'
     api4 = auth.login_another_user(self.url, self.phone4, self.code4)
     resp = api4.send_help(team_uid, email, text).json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 16
0
 def test_get_usage_exist_team(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     resp = self.api.get_team_usage(team_uid)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['uploads_size'] == 0
     assert resp['result']['uploads_size_limit'] == 1073741824
Exemplo n.º 17
0
 def test_upload_team_icon_member(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     func.add_contact(self.api, team_uid, self.phone2, role='member')
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.upload_team_icon(team_uid,
                                  os.path.join(const.TD_FILES, 'tiger.jpg'))
     resp = resp.json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 18
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
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 def test_get_team_valid_uid(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     name = resp['name']
     resp = self.api.get_team(team_uid)
     resp = resp.json()
     assert 'error' not in resp
     assert resp['result']['uid'] == team_uid
     assert resp['result']['name'] == name
Exemplo n.º 21
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']
Exemplo n.º 22
0
 def test_invite_one_contact_only_phone(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     data = {'phone': self.phone2}
     resp = self.api.add_contacts(team_uid, data).json()
     resp2 = self.api.get_contacts(team_uid).json()
     assert 'error' not in resp
     assert self.phone2 == resp['result']['contact_phone']
     assert self.phone2 == resp2['result'][0]['contact_phone']
Exemplo n.º 23
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
Exemplo n.º 24
0
 def test_get_sections_member(self):
     team_uid = func.add_team(self.api)['uid']
     func.add_contact(self.api, team_uid, self.phone2, 'member')['jid']
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.get_sections(team_uid)
     resp = resp.json()
     assert 'error' not in resp
     for item in resp['result']:
         assert 'name' in item
Exemplo n.º 25
0
 def test_invite_2_contacts_only_phone(self):
     resp = func.add_team(self.api)
     team_uid = resp['uid']
     data = {'contacts': [{'phone': self.phone2}, {'phone': self.phone3}]}
     data_json = json.dumps(data)
     resp = self.api.add_contacts(team_uid, data_json).json()
     assert 'error' not in resp
     assert self.phone2 == resp['result']['contacts'][0]['contact_phone']
     assert self.phone3 == resp['result']['contacts'][1]['contact_phone']
Exemplo n.º 26
0
 def test_send_help_upload_outsider(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     api4 = auth.login_another_user(self.url, self.phone4, self.code4)
     filename = 'word.docx'
     resp = api4.send_help_upload(team_uid,
                                  os.path.join(const.TD_FILES,
                                               filename)).json()
     assert resp['error'] == const.ACCESS_DENIED
Exemplo n.º 27
0
 def test_send_help_upload(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     filename = 'tiger.jpg'
     resp = self.api.send_help_upload(
         team_uid, os.path.join(const.TD_FILES, filename)).json()
     assert 'error' not in resp
     assert resp['result']['name'] == filename
     assert filename in resp['result']['url']
     assert resp['result']['size'] == 456822
Exemplo n.º 28
0
 def test_get_team_member(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     name = team['name']
     func.add_contact(self.api, team_uid, self.phone2, role='member')
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.get_team(team_uid).json()
     assert 'error' not in resp
     assert resp['result']['uid'] == team_uid
     assert resp['result']['name'] == name
Exemplo n.º 29
0
 def test_send_help_member(self):
     team = func.add_team(self.api)
     team_uid = team['uid']
     func.add_contact(self.api, team_uid, self.phone2, role='member')
     email = '*****@*****.**'
     text = 'I need help. This is member of team.'
     api2 = auth.login_another_user(self.url, self.phone2, self.code2)
     resp = api2.send_help(team_uid, email, text).json()
     assert 'error' not in resp
     assert resp['result'] == 'OK'
Exemplo n.º 30
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