Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
6255ee5c
Commit
6255ee5c
authored
Nov 14, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test avatar interactions
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
a79ca6a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletion
+60
-1
weblate/accounts/tests.py
weblate/accounts/tests.py
+60
-1
No files found.
weblate/accounts/tests.py
View file @
6255ee5c
...
...
@@ -25,6 +25,7 @@ Tests for user handling.
import
tempfile
from
unittest
import
TestCase
as
UnitTestCase
from
django.test
import
TestCase
from
django.utils.unittest
import
SkipTest
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
AnonymousUser
,
User
,
Group
from
django.core
import
mail
...
...
@@ -45,6 +46,7 @@ from weblate.accounts.models import (
from
weblate.accounts.captcha
import
(
hash_question
,
unhash_question
,
MathCaptcha
)
from
weblate.accounts
import
avatar
from
weblate.accounts.middleware
import
RequireLoginMiddleware
from
weblate.trans.tests.test_views
import
ViewTestCase
,
RegistrationTestMixin
...
...
@@ -239,7 +241,7 @@ class CommandTest(TestCase):
call_command
(
'importuserdata'
,
output
.
name
)
profile
=
Profile
.
objects
.
get
(
user__username
=
'testuser'
)
self
.
assertEqual
s
(
profile
.
translated
,
2000
)
self
.
assertEqual
(
profile
.
translated
,
2000
)
class
ViewTest
(
TestCase
):
...
...
@@ -664,3 +666,60 @@ class MiddlewareTest(TestCase):
self
.
assertIsNone
(
middleware
.
process_view
(
request
,
self
.
view_method
,
(),
{})
)
class
AvatarTest
(
ViewTestCase
):
def
setUp
(
self
):
super
(
AvatarTest
,
self
).
setUp
()
self
.
user
.
email
=
'test@example.com'
self
.
user
.
save
()
def
assert_url
(
self
):
url
=
avatar
.
avatar_for_email
(
self
.
user
.
email
)
self
.
assertEqual
(
'https://seccdn.libravatar.org/avatar/'
'55502f40dc8b7c769880b10874abc9d0'
,
url
.
split
(
'?'
)[
0
]
)
def
test_avatar_for_email_own
(
self
):
backup
=
avatar
.
HAS_LIBRAVATAR
try
:
avatar
.
HAS_LIBRAVATAR
=
False
self
.
assert_url
()
finally
:
avatar
.
HAS_LIBRAVATAR
=
backup
def
test_avatar_for_email_libravatar
(
self
):
if
not
avatar
.
HAS_LIBRAVATAR
:
raise
SkipTest
(
'Libravatar not installed'
)
self
.
assert_url
()
def
test_avatar
(
self
):
# Real user
response
=
self
.
client
.
get
(
reverse
(
'user_avatar'
,
kwargs
=
{
'user'
:
self
.
user
.
username
,
'size'
:
32
}
)
)
self
.
assertPNG
(
response
)
# Test caching
response
=
self
.
client
.
get
(
reverse
(
'user_avatar'
,
kwargs
=
{
'user'
:
self
.
user
.
username
,
'size'
:
32
}
)
)
self
.
assertPNG
(
response
)
def
test_anonymous_avatar
(
self
):
anonymous
=
User
.
objects
.
get
(
username
=
'anonymous'
)
# Anonymous user
response
=
self
.
client
.
get
(
reverse
(
'user_avatar'
,
kwargs
=
{
'user'
:
anonymous
.
username
,
'size'
:
32
}
)
)
self
.
assertPNG
(
response
)
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