Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
7c3fe6eb
authored
Apr 08, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: profile view test
parent
522b6bb3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
circle/dashboard/tests/test_views.py
+66
-0
No files found.
circle/dashboard/tests/test_views.py
View file @
7c3fe6eb
...
...
@@ -4,6 +4,7 @@ from django.contrib.auth.models import User, Group
from
django.core.exceptions
import
SuspiciousOperation
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
Permission
from
django.contrib.auth
import
authenticate
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
from
..models
import
Profile
...
...
@@ -774,3 +775,68 @@ class IndexViewTest(LoginMixin, TestCase):
self
.
u1
.
profile
.
notify
(
"urgent"
,
"dashboard/test_message.txt"
,
)
response
=
c
.
get
(
"/dashboard/"
)
self
.
assertEqual
(
response
.
context
[
'NEW_NOTIFICATIONS_COUNT'
],
1
)
class
ProfileViewTest
(
LoginMixin
,
TestCase
):
def
setUp
(
self
):
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
self
.
p1
=
Profile
.
objects
.
create
(
user
=
self
.
u1
)
self
.
p1
.
save
()
def
test_permitted_language_change
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user1"
)
old_language_cookie_value
=
c
.
cookies
[
'django_language'
]
.
value
old_language_db_value
=
self
.
u1
.
profile
.
preferred_language
response
=
c
.
post
(
"/dashboard/profile/"
,
{
'preferred_language'
:
"hu"
,
})
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertNotEqual
(
old_language_cookie_value
,
c
.
cookies
[
'django_language'
]
.
value
)
self
.
assertNotEqual
(
old_language_db_value
,
User
.
objects
.
get
(
username
=
"user1"
)
.
profile
.
preferred_language
)
def
test_permitted_valid_password_change
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user1"
)
c
.
post
(
"/dashboard/profile/"
,
{
'old_password'
:
"password"
,
'new_password1'
:
"asd"
,
'new_password2'
:
"asd"
,
})
self
.
assertIsNone
(
authenticate
(
username
=
"user1"
,
password
=
"password"
))
self
.
assertIsNotNone
(
authenticate
(
username
=
"user1"
,
password
=
"asd"
))
def
test_permitted_invalid_password_changes
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user1"
)
# wrong current password
c
.
post
(
"/dashboard/profile/"
,
{
'old_password'
:
"password1"
,
'new_password1'
:
"asd"
,
'new_password2'
:
"asd"
,
})
self
.
assertIsNotNone
(
authenticate
(
username
=
"user1"
,
password
=
"password"
))
self
.
assertIsNone
(
authenticate
(
username
=
"user1"
,
password
=
"asd"
))
# wrong pw confirmation
c
.
post
(
"/dashboard/profile/"
,
{
'old_password'
:
"password"
,
'new_password1'
:
"asd"
,
'new_password2'
:
"asd1"
,
})
self
.
assertIsNotNone
(
authenticate
(
username
=
"user1"
,
password
=
"password"
))
self
.
assertIsNone
(
authenticate
(
username
=
"user1"
,
password
=
"asd"
))
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