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
c11c6638
Commit
c11c6638
authored
Jan 18, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test custom registration
parent
ae413903
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
10 deletions
+66
-10
weblate/accounts/tests.py
weblate/accounts/tests.py
+66
-10
No files found.
weblate/accounts/tests.py
View file @
c11c6638
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
Replace this with more appropriate tests for your application.
"""
Tests for user handling.
"""
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
User
from
django.core
import
mail
class
RegistrationTest
(
TestCase
):
def
test_register
(
self
):
response
=
self
.
client
.
post
(
reverse
(
'weblate_register'
),
{
'username'
:
'username'
,
'email'
:
'noreply@weblate.org'
,
'password1'
:
'password'
,
'password2'
:
'password'
,
'first_name'
:
'First'
,
'last_name'
:
'Last'
,
}
)
# Check we did succeed
self
.
assertRedirects
(
response
,
reverse
(
'registration_complete'
))
# Check registration mail
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
].
subject
,
'Your registration on Weblate'
)
# Get confirmation URL from mail
line
=
''
for
line
in
mail
.
outbox
[
0
].
body
.
splitlines
():
if
line
.
startswith
(
'http://example.com'
):
break
# Confirm account
response
=
self
.
client
.
get
(
line
[
18
:])
self
.
assertRedirects
(
response
,
reverse
(
'registration_activation_complete'
)
)
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
user
=
User
.
objects
.
get
(
username
=
'username'
)
# Verify user is active
self
.
assertTrue
(
user
.
is_active
)
# Verify stored first/last name
self
.
assertEqual
(
user
.
first_name
,
'First'
)
self
.
assertEqual
(
user
.
last_name
,
'Last'
)
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