Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
7e35bf19
Commit
7e35bf19
authored
Apr 11, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1846 from MITx/feature/zoldak/test-user-profile-factory
Convert login tests to use factories
parents
dce0b53c
bb1134b8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
lms/djangoapps/courseware/tests/test_login.py
+8
-10
No files found.
lms/djangoapps/courseware/tests/test_login.py
View file @
7e35bf19
from
django.test
import
TestCase
from
django.test.client
import
Client
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
User
from
student.models
import
Registration
,
UserProfile
from
factories
import
UserFactory
,
RegistrationFactory
,
UserProfileFactory
import
json
class
LoginTest
(
TestCase
):
'''
Test student.views.login_user() view
'''
def
setUp
(
self
):
# Create one user and save it to the database
self
.
user
=
User
.
objects
.
create_user
(
'test'
,
'test@edx.org'
,
'test_password
'
)
self
.
user
.
is_active
=
True
self
.
user
=
User
Factory
.
build
(
username
=
'test'
,
email
=
'test@edx.org
'
)
self
.
user
.
set_password
(
'test_password'
)
self
.
user
.
save
()
# Create a registration for the user
Registration
()
.
register
(
self
.
user
)
registration
=
RegistrationFactory
(
user
=
self
.
user
)
registration
.
register
(
self
.
user
)
registration
.
activate
()
# Create a profile for the user
UserProfile
(
user
=
self
.
user
)
.
save
(
)
UserProfile
Factory
(
user
=
self
.
user
)
# Create the test client
self
.
client
=
Client
()
...
...
@@ -42,7 +43,6 @@ class LoginTest(TestCase):
response
=
self
.
_login_response
(
unicode_email
,
'test_password'
)
self
.
_assert_response
(
response
,
success
=
True
)
def
test_login_fail_no_user_exists
(
self
):
response
=
self
.
_login_response
(
'not_a_user@edx.org'
,
'test_password'
)
self
.
_assert_response
(
response
,
success
=
False
,
...
...
@@ -54,7 +54,6 @@ class LoginTest(TestCase):
value
=
'Email or password is incorrect'
)
def
test_login_not_activated
(
self
):
# De-activate the user
self
.
user
.
is_active
=
False
self
.
user
.
save
()
...
...
@@ -64,7 +63,6 @@ class LoginTest(TestCase):
self
.
_assert_response
(
response
,
success
=
False
,
value
=
"This account has not been activated"
)
def
test_login_unicode_email
(
self
):
unicode_email
=
u'test@edx.org'
+
unichr
(
40960
)
response
=
self
.
_login_response
(
unicode_email
,
'test_password'
)
...
...
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