From 81df96fa027519bc92fa91daa485ef1df9dbe19c Mon Sep 17 00:00:00 2001 From: YashSahsani Date: Sat, 22 Jun 2024 20:45:41 -0400 Subject: [PATCH] feat: add test and workflow --- .github/workflows/django.yml | 5 +---- Auth/tests.py | 5 +++-- Auth/views.py | 11 +---------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 0b9a218..263fce3 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -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 diff --git a/Auth/tests.py b/Auth/tests.py index ac79995..90e006a 100644 --- a/Auth/tests.py +++ b/Auth/tests.py @@ -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) diff --git a/Auth/views.py b/Auth/views.py index a4dec7f..e8f9e93 100644 --- a/Auth/views.py +++ b/Auth/views.py @@ -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): @@ -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: