Compare commits
No commits in common. "a13feba991eb63b7380472a8cde6a904283d393f" and "22ff3d58d3208ab8493a63425b401f2ed6c0ca40" have entirely different histories.
a13feba991
...
22ff3d58d3
@ -9,13 +9,12 @@ class Client:
|
||||
def __init__(self, url: str):
|
||||
self.url: str = url
|
||||
self.token: str = None
|
||||
self.csrf_token: str = None
|
||||
self.session: Session = Session()
|
||||
self.accounts: Accounts = Accounts(self)
|
||||
self.profiles: Profiles = Profiles(self)
|
||||
|
||||
def is_authentificate(self):
|
||||
return (self.token is not None)
|
||||
return (not self.token is None)
|
||||
|
||||
def login(self, username: str, password: str):
|
||||
response: Response = self._post(urls.accounts_login, {'username': username, 'password': password})
|
||||
@ -23,16 +22,16 @@ class Client:
|
||||
|
||||
def _post(self, uri: str, data: dict = {}):
|
||||
url: str = self.url + uri
|
||||
if self.csrf_token is None:
|
||||
if self.token is None:
|
||||
response: Response = self.session.get(url)
|
||||
self.csrf_token = response.cookies.get('csrftoken')
|
||||
data.update({'csrfmiddlewaretoken': self.csrf_token})
|
||||
self.token = response.cookies.get('csrftoken')
|
||||
data.update({'csrfmiddlewaretoken': self.token})
|
||||
response: Response = self.session.post(url, data = data, headers = dict(Referer=url))
|
||||
self.csrf_token = response.cookies.get('csrftoken')
|
||||
self.token = response.cookies.get('csrftoken')
|
||||
return response
|
||||
|
||||
def _get(self, uri: str):
|
||||
url: str = self.url + uri
|
||||
response: Response = self.session.get(url)
|
||||
self.csrf_token = response.cookies.get('csrftoken')
|
||||
self.token = response.cookies.get('csrftoken')
|
||||
return response
|
@ -1,7 +1,6 @@
|
||||
def test(func: callable, params, expected_value, title: str, description = None):
|
||||
print(title, end=" ")
|
||||
value = func(*params)
|
||||
if (value == expected_value):
|
||||
if (func(*params) == expected_value):
|
||||
print("[OK]")
|
||||
return
|
||||
print ("[ERROR]")
|
||||
|
Loading…
Reference in New Issue
Block a user