diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 56bbcb2..6ade1f9 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -25,3 +25,4 @@ jobs: uses: astral-sh/ruff-action@v3.2.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} + - run: ruff format --check diff --git a/promo_code/user/tests/user/operations/test_profile.py b/promo_code/user/tests/user/operations/test_profile.py index 3d6e365..98bde2d 100644 --- a/promo_code/user/tests/user/operations/test_profile.py +++ b/promo_code/user/tests/user/operations/test_profile.py @@ -14,7 +14,9 @@ def setUp(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, signup_data, format='json', + self.signup_url, + signup_data, + format='json', ) token = response.data.get('access') self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + token) @@ -23,7 +25,8 @@ def setUp(self): def test_get_profile_initial(self): response = self.client.get(self.user_profile_url, format='json') self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) expected = { 'name': 'Steve', @@ -36,10 +39,13 @@ def test_get_profile_initial(self): def test_patch_profile_update_name_and_surname(self): payload = {'name': 'John', 'surname': 'Tsal'} response = self.client.patch( - self.user_profile_url, payload, format='json', + self.user_profile_url, + payload, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) self.assertEqual(response.data.get('name'), 'John') self.assertEqual(response.data.get('surname'), 'Tsal') @@ -47,13 +53,17 @@ def test_patch_profile_update_name_and_surname(self): def test_patch_profile_update_avatar_url(self): payload = {'avatar_url': 'http://nodomain.com/kitten.jpeg'} response = self.client.patch( - self.user_profile_url, payload, format='json', + self.user_profile_url, + payload, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) self.assertEqual( - response.data.get('avatar_url'), 'http://nodomain.com/kitten.jpeg', + response.data.get('avatar_url'), + 'http://nodomain.com/kitten.jpeg', ) def test_patch_password_and_check_persistence(self): @@ -69,10 +79,13 @@ def test_patch_password_and_check_persistence(self): format='json', ) response = self.client.patch( - self.user_profile_url, {'password': new_password}, format='json', + self.user_profile_url, + {'password': new_password}, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) data = response.data self.assertEqual(data.get('name'), 'John') @@ -80,19 +93,23 @@ def test_patch_password_and_check_persistence(self): self.assertEqual(data.get('email'), 'creator@apple.com') self.assertEqual(data.get('other'), {'age': 23, 'country': 'us'}) self.assertEqual( - data.get('avatar_url'), 'http://nodomain.com/kitten.jpeg', + data.get('avatar_url'), + 'http://nodomain.com/kitten.jpeg', ) # test old token still valid response = self.client.get(self.user_profile_url, format='json') self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) def test_auth_sign_in_old_password_fails(self): new_password = 'MegaGiant88888@dooRuveS' response = self.client.patch( - self.user_profile_url, {'password': new_password}, format='json', + self.user_profile_url, + {'password': new_password}, + format='json', ) self.client.credentials() response = self.client.post( @@ -104,13 +121,16 @@ def test_auth_sign_in_old_password_fails(self): format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_401_UNAUTHORIZED, + response.status_code, + rest_framework.status.HTTP_401_UNAUTHORIZED, ) def test_auth_sign_in_new_password_succeeds(self): new_password = 'MegaGiant88888@dooRuveS' response = self.client.patch( - self.user_profile_url, {'password': new_password}, format='json', + self.user_profile_url, + {'password': new_password}, + format='json', ) self.client.credentials() response = self.client.post( @@ -122,5 +142,6 @@ def test_auth_sign_in_new_password_succeeds(self): format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) diff --git a/promo_code/user/tests/user/validations/test_profile_validation.py b/promo_code/user/tests/user/validations/test_profile_validation.py index d3881a8..9bbd943 100644 --- a/promo_code/user/tests/user/validations/test_profile_validation.py +++ b/promo_code/user/tests/user/validations/test_profile_validation.py @@ -15,7 +15,9 @@ def setUp(self): 'other': {'age': 48, 'country': 'gb'}, } response = self.client.post( - self.signup_url, signup_data, format='json', + self.signup_url, + signup_data, + format='json', ) token = response.data.get('access') self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + token) @@ -23,10 +25,13 @@ def setUp(self): def test_update_profile_empty_name_and_surname(self): payload = {'name': '', 'surname': ''} response = self.client.patch( - self.user_profile_url, payload, format='json', + self.user_profile_url, + payload, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, + response.status_code, + rest_framework.status.HTTP_400_BAD_REQUEST, ) @parameterized.parameterized.expand( @@ -39,10 +44,13 @@ def test_update_profile_empty_name_and_surname(self): def test_update_profile_invalid_avatar_url(self, name, url): payload = {'avatar_url': url} response = self.client.patch( - self.user_profile_url, payload, format='json', + self.user_profile_url, + payload, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, + response.status_code, + rest_framework.status.HTTP_400_BAD_REQUEST, ) @parameterized.parameterized.expand( @@ -61,16 +69,20 @@ def test_update_profile_invalid_avatar_url(self, name, url): def test_update_profile_weak_password(self, name, pwd): payload = {'password': pwd} response = self.client.patch( - self.user_profile_url, payload, format='json', + self.user_profile_url, + payload, + format='json', ) self.assertEqual( - response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, + response.status_code, + rest_framework.status.HTTP_400_BAD_REQUEST, ) def test_get_profile(self): response = self.client.get(self.user_profile_url, format='json') self.assertEqual( - response.status_code, rest_framework.status.HTTP_200_OK, + response.status_code, + rest_framework.status.HTTP_200_OK, ) expected = { 'name': 'Jack',