Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-base
Manage
Activity
Members
Labels
Plan
Issues
51
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Håvard Farestveit
tdt4242-base
Commits
dc1dfd4f
Commit
dc1dfd4f
authored
3 years ago
by
Elias Larsen
Browse files
Options
Downloads
Patches
Plain Diff
validate test passer ikke
parent
5671dd09
Branches
userserializer_automated_tests
Branches containing commit
No related tags found
1 merge request
!4
Userserializer automated tests
Pipeline
#114683
passed with stages
Stage:
Stage:
Stage:
in 1 minute and 11 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/secfit/users/tests.py
+32
-6
32 additions, 6 deletions
backend/secfit/users/tests.py
with
32 additions
and
6 deletions
backend/secfit/users/tests.py
+
32
−
6
View file @
dc1dfd4f
from
django.test
import
TestCase
from
.serializers
import
UserSerializer
from
django.contrib.auth
import
get_user_model
from
rest_framework
import
serializers
class
UserSerializerTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
user_model
=
get_user_model
()
def
test_create
(
self
):
data
=
{
user
=
self
.
user_model
(
username
=
"
test
"
,
email
=
"
test@test.com
"
,
phone_number
=
"
12345678
"
,
country
=
"
Norway
"
,
city
=
"
Oslo
"
,
street_address
=
"
address 10
"
)
password
=
"
password
"
user
.
set_password
(
password
)
user
.
save
()
self
.
data
=
{
"
username
"
:
"
testCreate
"
,
"
email
"
:
"
test@test.com
"
,
"
password
"
:
"
1
"
,
...
...
@@ -18,9 +28,25 @@ class UserSerializerTestCase(TestCase):
"
city
"
:
"
Oslo
"
,
"
street_address
"
:
"
address 10
"
}
user_create
=
UserSerializer
.
create
(
UserSerializer
(),
validated_data
=
data
)
self
.
data1
=
{
"
username
"
:
"
testCreate
"
,
"
email
"
:
"
test@test.com
"
,
"
password
"
:
""
,
"
password1
"
:
""
,
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
Norway
"
,
"
city
"
:
"
Oslo
"
,
"
street_address
"
:
"
address 10
"
}
def
test_create
(
self
):
user_create
=
UserSerializer
.
create
(
UserSerializer
(),
validated_data
=
self
.
data
)
self
.
assertEqual
(
self
.
user_model
.
objects
.
get
(
username
=
"
testCreate
"
),
user_create
)
def
test_validate_password
(
self
):
response
=
UserSerializer
.
validate_password
(
UserSerializer
(),
{})
self
.
assertEqual
(
response
,
{})
response
=
UserSerializer
(
data
=
self
.
data1
).
validate_password
(
value
=
"
WrongPassword
"
)
self
.
assertRaises
(
serializers
.
ValidationError
,
UserSerializer
.
validate_password
,
UserSerializer
(
data
=
self
.
data1
),
response
)
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