Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prepush): adjusts pre-commit to run tests in shell #181

Merged
merged 9 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
stages: [pre-push]
- id: django-test
name: 'Checking Tests'
entry: python manage.py test
entry: pipenv run python manage.py test
always_run: true
pass_filenames: false
language: system
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ sentry-sdk = {extras = ["django"], version = "*"}
pytz = "*"
redis = "*"
coverage = "*"
celery = "*"
django-celery-beat = "*"
pre-commit = "*"
celery = "*"

[dev-packages]
flake8 = "*"
Expand Down
22 changes: 11 additions & 11 deletions Pipfile.lock
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GitLukeW During the process of debugging, I uninstalled and reinstalled celery. When I did this, I also ran pipenv install and it looks like it updated boto3 as well. Do you think this is going to cause an issue? If so I can work on reverting it.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,18 @@ Below are the commands and expected outputs:

```bash
pre-commit install
pre-commit installed at .git/hooks/pre-commit
```
`pre-commit installed at .git/hooks/pre-commit`

```bash
pre-commit install --hook-type commit-msg
pre-commit installed at .git/hooks/commit-msg
```
`pre-commit installed at .git/hooks/commit-msg`

```bash
pre-commit install --hook-type pre-push
```
`pre-commit installed at .git/hooks/pre-push`

To run the pre-commit checks before making a commit, run the following command.

Expand All @@ -349,11 +356,9 @@ pre-commit run --all-files

If no files need changes, the output should look like this:

```bash
isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Passed
```
`isort....................................................................Passed`
`black....................................................................Passed`
`flake8...................................................................Passed`

If isort or black catch any errors, they will automatically alter the files to fix them.
This will prevent making a commit, and you will need to stage the new changes.
Expand Down
2 changes: 1 addition & 1 deletion team_production_system/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from .models import (
Availability,
CustomUser,
Expand All @@ -18,7 +19,6 @@ class SessionAdmin(admin.ModelAdmin):
readonly_fields = ('created_at', 'modified_at')


# admin.site.register(UserAdmin)
admin.site.register(CustomUser, UserAdmin)
admin.site.register(Mentor)
admin.site.register(Mentee)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APIClient

from team_production_system.models import CustomUser


class UserProfilePatchTestCase(TestCase):
def setUp(self):
self.client = APIClient()
self.user = CustomUser.objects.create(
username="baby_yoda",
email="[email protected]",
password="badpassword"
username='baby_yoda', email='[email protected]', password='badpassword'
)

def test_new_user_gets_random_photo_assigned(self):
Expand All @@ -22,14 +21,12 @@ def test_new_user_gets_random_photo_assigned(self):
def test_profile_photo_uploaded_first_time(self):
# mock photo file
photo = SimpleUploadedFile(
"photo.jpg",
b"this is a photo",
content_type="image/jpeg"
'photo.jpg', b'this is a photo', content_type='image/jpeg'
)
# Make a PATCH request to update the user profile with the new photo
url = reverse("my-profile")
url = reverse('my-profile')
self.client.force_authenticate(user=self.user)
response = self.client.patch(url, {"profile_photo": photo})
response = self.client.patch(url, {'profile_photo': photo})

# Check that the response status code is 200 OK
self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand All @@ -43,15 +40,13 @@ def test_previous_file_deleted_when_new_photo_saved(self):
old_photo_name = self.user.profile_photo.name
# Create a new profile photo file
new_photo = SimpleUploadedFile(
"new_photo.jpg",
b"this is a new photo",
content_type="image/jpeg"
'new_photo.jpg', b'this is a new photo', content_type='image/jpeg'
)

# Make a PATCH request to update the user profile with the new photo
url = reverse("my-profile")
url = reverse('my-profile')
self.client.force_authenticate(user=self.user)
response = self.client.patch(url, {"profile_photo": new_photo})
response = self.client.patch(url, {'profile_photo': new_photo})

# Check that the response status code is 200 OK
self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down