Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
55 changes: 55 additions & 0 deletions data/ShoeExpert/app1/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@
from django.test import TestCase
from django.test import LiveServerTestCase
from selenium import WebDriver
from selenium.webdriver.common.keys import Keys

# Create your tests here.

class LoginFormTest(LiveServerTestCase):

def testLogin(self):
selenium = webdriver.Chrome()
#Choose your url to visit
selenium.get('http://127.0.0.1:8000/')
#find the elements you need to submit form
username = selenium.find_element_by_id('username')
password = selenium.find_element_by_id('password')

submit = selenium.find_element_by_id('login')

#populate the form with data
username.send_keys('docker')
password.send_keys('docker')

#submit form
submit.send_keys(Keys.RETURN)

#check result; page source looks at entire html document
body = self.browser.find_element_by_tag_name('body')
self.assertIn('Home', body.text)


class JoinFormTest(LiveServerTestCase):

def testLogin(self):
selenium = webdriver.Chrome()
#Choose your url to visit
selenium.get('http://127.0.0.1:8000/join')
#find the elements you need to submit form
username = selenium.find_element_by_id('username')
password = selenium.find_element_by_id('password')
first_name = selenium.find_element_by_id('name')
last_name = selenium.find_element_by_id('name')
email = selenium.find_element_by_id('email')

submit = selenium.find_element_by_id('join')

#populate the form with data
username.send_keys('testUser')
password.send_keys('testPass')
first_name.send_keys('firstName')
last_name.send_keys('lastName')
email.send_keys('test@gmail.com')

#submit form
submit.send_keys(Keys.RETURN)

#check result; page source looks at entire html document
assert 'testUser' in selenium.page_source
2 changes: 1 addition & 1 deletion data/ShoeExpert/templates/app1/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<body>
<div class="container">
<h1> Test about </h1>
<h1> Blog Page </h1>
</div>
</body>

Expand Down
12 changes: 12 additions & 0 deletions data/ShoeExpert/templates/app1/filter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

<html>

{% include "app1/head.html" %}

<body>
<div class="container">
<h1> Filterig Page </h1>
</div>
</body>

</html>
1 change: 1 addition & 0 deletions data/ShoeExpert/templates/app1/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<body>
<div class="container-fluid" style="height: 90%; overflow-y: scroll;">
<h1> Home </h1>

{% for shoe_dict in context_list %}
<div class="card mb-3" style="background-color: rgba(150, 165, 210, 0.8);">
Expand Down
2 changes: 1 addition & 1 deletion data/ShoeExpert/templates/app1/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>Login</h1>
<tr><td></td></tr>
<tr>
<td>
<a class="btn btn-success" href="/join" role="button">Create Account</a>
<a class="btn btn-success" href="/join" role="button" id="login">Create Account</a>
</td>
</tr>
</table>
Expand Down
5 changes: 4 additions & 1 deletion data/ShoeExpert/templates/app1/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
<a class="nav-link" href="/about"> About </a>

</li>
{%if user.is_authenticated%}
<li class="nav-item">
<a class="nav-link" href="/blog"> Blog </a>
</li>
{%if user.is_authenticated%}
<li class="nav-item">
<a class="nav-link" href="/blog"> Filter </a>
</li>
<li class="nav-item">
<a class="nav-link" href="/logout">Logout ({{user.username}})</a>
</li>
Expand Down