Skip to content

Commit

Permalink
fix: change error lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 21, 2024
1 parent 33535ee commit b83734c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
10 changes: 3 additions & 7 deletions apps/users/api_endpoints/UserProfile/UserProfileDestroy/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ class UserProfileDestroyTest(APITestCase):

def setUp(self):
self.user = User.objects.create(
username="Akromjon",
password="password",
is_active=True
username="Akromjon", password="password", is_active=True
)

refresh_token = RefreshToken.for_user(self.user)
self.token = str(refresh_token.access_token)

def test_destroy(self):
url = reverse(
"users:userprofile-destroy", kwargs={"pk": self.user.profiles.id}
)
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + self.token)
url = reverse("users:userprofile-destroy", kwargs={"pk": self.user.profiles.id})
self.client.credentials(HTTP_AUTHORIZATION="Bearer " + self.token)

response = self.client.delete(url)

Expand Down
13 changes: 5 additions & 8 deletions apps/users/api_endpoints/Users/ForgotPassword/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ class ForgotPasswordTest(APITestCase):
def setUp(self):

self.user = User.objects.create(
username="Akromjon",
username="Akromjon",
email="[email protected]",
password="password",
is_active=True
is_active=True,
)

refres_token = RefreshToken.for_user(self.user)
self.token = str(refres_token.access_token)


def test_forgot(self):
url = reverse("users:forgot-password")

self.client.credentials(HTTP_AUTHORIZATION="Bearer " + self.token)

data={"email": "[email protected]"}
data = {"email": "[email protected]"}

response = self.client.post(
url, data=data
)
response = self.client.post(url, data=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.json()["detail"],
Expand Down
12 changes: 4 additions & 8 deletions apps/users/api_endpoints/Users/UpdatePasswordByEmail/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@
class UpdatePasswordTest(APITestCase):
def setUp(self):
self.user = User.objects.create(
username="Akromjon",
username="Akromjon",
email="[email protected]",
password="password",
is_active=True
is_active=True,
)
refresh_token = RefreshToken.for_user(self.user)
self.token = str(refresh_token.access_token)


def test_update(self):
url = reverse(
"users:user-password-update", kwargs={"token": self.user.token}
)
url = reverse("users:user-password-update", kwargs={"token": self.user.token})
self.client.credentials(HTTP_AUTHORIZATION="Bearer " + self.token)
data = {
"password1": "2007",
Expand All @@ -28,6 +25,5 @@ def test_update(self):
"new_password": "0000",
}
response = self.client.put(url, data=data)

self.assertEqual(response.status_code, 200)

self.assertEqual(response.status_code, 200)
11 changes: 5 additions & 6 deletions apps/users/api_endpoints/Users/UserActivation/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
class UserActivateTest(APITestCase):
def setUp(self):
self.user = User.objects.create(
username="Akrom",
username="Akrom",
email="[email protected]",
password="password",
is_active=True
is_active=True,
)
refresh_token = RefreshToken.for_user(self.user)
self.token = str(refresh_token.access_token)

def test_activation(self):
activation_user = User.objects.create(
username="Munisa",
email="[email protected]",
password="password"
username="Munisa", email="[email protected]", password="password"
)
self.client.credentials(HTTP_AUTHORIZATION="Bearer " + self.token)
url = reverse("users:user-activation", kwargs={"token": activation_user.token})
Expand All @@ -28,5 +26,6 @@ def test_activation(self):

self.assertEqual(response.status_code, 200)
self.assertEqual(
response.json()["detail"], f"{activation_user.username} successfully activated"
response.json()["detail"],
f"{activation_user.username} successfully activated",
)
4 changes: 2 additions & 2 deletions apps/users/api_endpoints/Users/UserCreate/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def setUp(self) -> None:
username="Akromjon",
email="[email protected]",
password="2007",
is_active=True
is_active=True,
)
refresh_token = RefreshToken.for_user(self.user)
self.token = str(refresh_token.access_token)

def test_create(self):
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + self.token)
self.client.credentials(HTTP_AUTHORIZATION="Bearer " + self.token)
url = reverse("users:user-create")
for _ in range(5):
password = fake.password()
Expand Down

0 comments on commit b83734c

Please sign in to comment.