Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bcd703b6
authored
Jun 11, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: tests for views: logout, login
parent
64910198
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
school/tests.py
+32
-0
No files found.
school/tests.py
View file @
bcd703b6
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.client
import
Client
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
models
import
create_user_profile
,
Person
,
Course
,
Semester
,
Group
from
models
import
create_user_profile
,
Person
,
Course
,
Semester
,
Group
...
@@ -184,3 +185,34 @@ class GroupTestCase(TestCase):
...
@@ -184,3 +185,34 @@ class GroupTestCase(TestCase):
def
test_get_absolute_url
(
self
):
def
test_get_absolute_url
(
self
):
self
.
assertIsNotNone
(
self
.
testgroup
.
get_absolute_url
())
self
.
assertIsNotNone
(
self
.
testgroup
.
get_absolute_url
())
class
ViewTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
Client
()
self
.
http_headers
=
{
'niifPersonOrgID'
:
'ABUZER'
,
'niifEduPersonHeldCourse'
:
''
,
'niifEduPersonAttendedCourse'
:
''
,
'givenName'
:
'User'
,
'sn'
:
'Test'
,
'email'
:
'test.user@testsite.hu'
}
def
test_logout
(
self
):
resp
=
self
.
client
.
get
(
'/logout/'
,
follow
=
False
)
self
.
assertEqual
(
302
,
resp
.
status_code
)
def
test_login
(
self
):
resp
=
self
.
client
.
get
(
'/login/'
,
follow
=
True
,
**
self
.
http_headers
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
def
test_login_without_id
(
self
):
del
self
.
http_headers
[
'niifPersonOrgID'
]
resp
=
self
.
client
.
get
(
'/login/'
,
follow
=
True
,
**
self
.
http_headers
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
for
(
url
,
_
)
in
resp
.
redirect_chain
:
self
.
assertIn
(
'/admin'
,
url
)
def
test_login_without_email
(
self
):
del
self
.
http_headers
[
'email'
]
resp
=
self
.
client
.
get
(
'/login/'
,
follow
=
True
,
**
self
.
http_headers
)
print
resp
.
status_code
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment