Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
8486af9e
Commit
8486af9e
authored
6 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Add tests to cover the new profile usecases
parent
d8afca69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/apply/users/tests/factories.py
+5
-0
5 additions, 0 deletions
opentech/apply/users/tests/factories.py
opentech/apply/users/tests/test_views.py
+37
-0
37 additions, 0 deletions
opentech/apply/users/tests/test_views.py
with
42 additions
and
0 deletions
opentech/apply/users/tests/factories.py
+
5
−
0
View file @
8486af9e
...
@@ -20,6 +20,7 @@ class UserFactory(factory.DjangoModelFactory):
...
@@ -20,6 +20,7 @@ class UserFactory(factory.DjangoModelFactory):
email
=
factory
.
Sequence
(
'
email{}@email.com
'
.
format
)
email
=
factory
.
Sequence
(
'
email{}@email.com
'
.
format
)
full_name
=
factory
.
Faker
(
'
name
'
)
full_name
=
factory
.
Faker
(
'
name
'
)
password
=
factory
.
PostGenerationMethodCall
(
'
set_password
'
,
'
defaultpassword
'
)
@factory.post_generation
@factory.post_generation
def
groups
(
self
,
create
,
extracted
,
**
kwargs
):
def
groups
(
self
,
create
,
extracted
,
**
kwargs
):
...
@@ -32,6 +33,10 @@ class UserFactory(factory.DjangoModelFactory):
...
@@ -32,6 +33,10 @@ class UserFactory(factory.DjangoModelFactory):
self
.
groups
.
add
(
groups
)
self
.
groups
.
add
(
groups
)
class
OAuthUserFactory
(
UserFactory
):
password
=
factory
.
PostGenerationMethodCall
(
'
set_unusable_password
'
)
class
AdminFactory
(
UserFactory
):
class
AdminFactory
(
UserFactory
):
is_admin
=
True
is_admin
=
True
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/users/tests/test_views.py
0 → 100644
+
37
−
0
View file @
8486af9e
from
django.test
import
TestCase
from
django.urls
import
reverse
from
.factories
import
OAuthUserFactory
,
UserFactory
class
TestProfileView
(
TestCase
):
def
setUp
(
self
):
self
.
user
=
UserFactory
()
self
.
url
=
reverse
(
'
users:account
'
)
def
test_cant_acces_if_not_logged_in
(
self
):
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertRedirects
(
response
,
reverse
(
'
users:login
'
)
+
'
?next=
'
+
self
.
url
)
def
test_includes_change_password
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertContains
(
response
,
reverse
(
'
users:password_change
'
))
def
test_doesnt_includes_change_password_for_oauth
(
self
):
self
.
client
.
force_login
(
OAuthUserFactory
())
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertNotContains
(
response
,
reverse
(
'
users:password_change
'
))
def
test_email_unique
(
self
):
other_user
=
UserFactory
()
self
.
client
.
post
(
self
.
url
,
data
=
{
'
email
'
:
other_user
.
email
})
self
.
user
.
refresh_from_db
()
self
.
assertNotEqual
(
self
.
user
.
email
,
other_user
.
email
)
def
test_can_change_email
(
self
):
new_email
=
'
me@another.com
'
self
.
client
.
force_login
(
self
.
user
)
self
.
client
.
post
(
self
.
url
,
data
=
{
'
email
'
:
new_email
})
self
.
user
.
refresh_from_db
()
self
.
assertEqual
(
self
.
user
.
email
,
new_email
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment