Skip to content

Commit

Permalink
feat: add test and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
YashSahsani committed Jun 23, 2024
1 parent 5415b17 commit 81df96f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Django CI
name: Django Test CI

on:
push:
branches: [ "master" ,"feat/*"]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
Expand Down
5 changes: 3 additions & 2 deletions Auth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def test_post_signup_failure(self):
response = self.client.post(reverse('Auth:signup'), {
'first_name': 'test',
'last_name': 'user',
'email': 'test2@t.com',
'email': 'test@test.com',
'password1': 'testpassword',
'password2': 'testpassword'
'password2': 'testpassword2'
})
self.assertEqual(response.status_code, 302)
self.assertRedirects(response, reverse('Auth:signup'))
messages_list = list(messages.get_messages(response.wsgi_request))
self.assertEqual(len(messages_list), 1)
Expand Down
11 changes: 1 addition & 10 deletions Auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ def get(self, request):

def post(self, request):
form = SignupForm(request.POST)
print("form:"+str(form.is_valid()))
if form.is_valid():
form.save()
messages.success(request, str(form.cleaned_data.get('first_name'))+' account has been created successfully. Please login to continue.')
return redirect('Auth:login')
else:
print(form.errors)
messages.error(request, 'Please check your inputs')
return redirect('Auth:signup', {'form': form})
return redirect('Auth:signup')


def forgot_password(request):
Expand All @@ -68,23 +66,16 @@ def forgot_password(request):

def reset_password(request):
email = request.GET.get('email')
print("email:"+str(email))
if not email:
messages.error(request, 'Invalid password reset link.')
return redirect('forgot_password')
print(request.method)
if request.method == 'POST':
form = ResetPasswordForm(request.POST, email=email)
print("form:"+str(form.is_valid()))
print("form:"+str(form.errors))
if form.is_valid():
user = User.objects.filter(email=email).first()
print("user:"+str(user))
if user:
print("password:"+str(form.cleaned_data['password1']))
user.set_password(form.cleaned_data['password1'])
user.save()
print("saved:")
messages.success(request, 'Your password has been successfully reset.')
return redirect(reverse('Auth:login'))
else:
Expand Down

0 comments on commit 81df96f

Please sign in to comment.