Skip to content

Instantly share code, notes, and snippets.

@MargaritaLubimova
Last active August 22, 2017 15:35
Show Gist options
  • Save MargaritaLubimova/4bbb907d78a713b0e7a56e8d2b04fff6 to your computer and use it in GitHub Desktop.
Save MargaritaLubimova/4bbb907d78a713b0e7a56e8d2b04fff6 to your computer and use it in GitHub Desktop.
def post_data_to_url(self, url, user_info, headers=None, access_token=None):
if headers is None:
if access_token is None:
head = self.dict_config['head']
else:
head = self.dict_config['head'].copy()
head.update({'X-PG-Authorization': access_token})
else:
head = headers
allure.MASTER_HELPER.attach("url", str(url))
allure.MASTER_HELPER.attach('Отправляемые данные', str(user_info))
response = requests.request("POST", url, data=json.dumps(user_info), headers=head)
allure.MASTER_HELPER.attach('api-response', str(response))
response = json.loads(response.text)
self.success_check(response)
return response
def user_registration(base_url, user_type, login, password):
"""
Registration the user
:param base_url: out config.json
:param user_type: if applicant user_type = 4, if employer user_type = 8
:param login: login, what user take
:param password: password, what user take
:return: response from api
"""
registration = False
while not registration:
url = base_url + "user/register/"
user_info = {
"login": login,
"password": password,
"type": user_type}
allure.MASTER_HELPER.attach("отсылаемые данные", str(user_info))
request = Helpers().post_data_to_url(url, user_info)
registration = UserService().success_registration(request)
return request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment