-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished faq and contact page and added testing
- Loading branch information
Showing
9 changed files
with
646 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.