-
Notifications
You must be signed in to change notification settings - Fork 0
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
Finished faq and contact page and added testing #90
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
|
||
<div class="col-md-6 offset-md-3"> | ||
<h1 class="mb-4" style="text-align: center;">Contact Us</h1> | ||
<p><strong>If you have any other questions, please feel free to contact us | ||
and our team will get back to you.</strong> </p> | ||
</br> | ||
<form method="POST" action="{% url 'contact_us' %}"> | ||
{% csrf_token %} | ||
<div class="mb-3"> | ||
<input type="email" class="form-control" name="email", placeholder="Email" required> | ||
</div> | ||
</br> | ||
<div class="mb-3"> | ||
<textarea name="question" class="form-control" placeholder="Enter your question here" required></textarea> | ||
</div> | ||
</br> | ||
<button type="send" style="margin-right: 7rem;" class="btn btn-outline-primary">Send</button> | ||
</form> | ||
</div> | ||
|
||
|
||
|
||
</div> | ||
|
||
{% endblock %} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comprehensive FAQ page, which will be really useful in our website |
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detailed test cases which will be really useful |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from django.test import TestCase | ||
from django.core import mail | ||
from django.urls import reverse | ||
from django.contrib.auth.models import User | ||
from django.contrib import auth | ||
|
||
class TestContactForm(TestCase): | ||
|
||
def setUp(self) -> None: | ||
user = User.objects.create_user(username='test3', email = 'test3@hotmailtestttt.com', password='passpass22') | ||
return super().setUp() | ||
|
||
def test_contact_form_successful(self): | ||
response = self.client.post(reverse("home"), { | ||
'username':'test3', | ||
'password':'passpass22'}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEqual(response.status_code, 200) | ||
|
||
#Should return true if user is logged in | ||
self.assertTrue(response.context['user'].is_authenticated) | ||
|
||
#Makes a post request to the contact form on contact us page | ||
response = self.client.post(reverse("contact_us"), { | ||
'email':'test3@hotmailtestttt.com', | ||
'question':'Can I have a summary generated in a different language?' | ||
}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEquals(response.status_code, 200) | ||
|
||
#check to see that if one email was sent | ||
self.assertEqual(len(mail.outbox), 1) | ||
#check to see if the subject line for email was correct | ||
self.assertEquals(mail.outbox[0].subject, "Question from test3@hotmailtestttt.com") | ||
|
||
def test_contact_form_invalid_email(self): | ||
response = self.client.post(reverse("home"), { | ||
'username':'test3', | ||
'password':'passpass22'}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEqual(response.status_code, 200) | ||
|
||
#Should return true if user is logged in | ||
self.assertTrue(response.context['user'].is_authenticated) | ||
|
||
#Makes a post request to the contact form on contact us page passing an invalid email | ||
response = self.client.post(reverse("contact_us"), { | ||
'email':'h', | ||
'question':'Can I have a summary generated in a different language?' | ||
}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEquals(response.status_code, 200) | ||
|
||
#check to see that if no email was sent since the form is invalid | ||
self.assertEqual(len(mail.outbox), 0) | ||
|
||
def test_contact_form_invalid_question(self): | ||
response = self.client.post(reverse("home"), { | ||
'username':'test3', | ||
'password':'passpass22'}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEqual(response.status_code, 200) | ||
|
||
#Should return true if user is logged in | ||
self.assertTrue(response.context['user'].is_authenticated) | ||
|
||
#Makes a post request to the contact form on contact us page passing an empty question | ||
response = self.client.post(reverse("contact_us"), { | ||
'email':'bob12@hotmaill.commm', | ||
'question':'' | ||
}, follow=True) | ||
|
||
#check if post response was a success | ||
self.assertEquals(response.status_code, 200) | ||
#check to see that if no email was sent since the form is invalid | ||
self.assertEqual(len(mail.outbox), 0) | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, everything follows our general website conventions