Skip to content

Commit

Permalink
LinkedInLearning#1 added test script for home app
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamaine committed Feb 16, 2024
1 parent cf56580 commit bcaee19
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
22 changes: 22 additions & 0 deletions home/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from django.contrib.auth.models import User

def test_home_view(client):
response = client.get(path='/')
assert response.status_code==200
assert 'Welcome to SmartNotes!' in str(response.content)

def test_signup(client):
response = client.get(path='/signup')
assert response.status_code==200
assert 'home/register.html' in response.template_name

#create temporary test database
@pytest.mark.django_db
def test_signup_authenticated(client):
user= User.objects.create_user('Kim','[email protected]','password')
client.login(username= user.username, password = 'password')
#follow= true means follow the url status code in this example a url is redirected will return code 302
response = client.get(path='/signup',follow=True)
assert 200 == response.status_code
assert 'notes/notes_list.html' in response.template_name
7 changes: 7 additions & 0 deletions notes/test_notes_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from django.contrib.auth.models import User

@pytest.mark.django_db
def test_list_endpoint_return_user_notes(client):
user= User.objects.create_user('Kim','[email protected]','password')
client.login(username= user.username, password = 'password')
3 changes: 0 additions & 3 deletions notes/tests.py

This file was deleted.

2 changes: 0 additions & 2 deletions smartnotes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand Down

0 comments on commit bcaee19

Please sign in to comment.