Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-base-APU
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
Tor Martin Frøberg Wang
tdt4242-base-APU
Commits
ff17385c
Commit
ff17385c
authored
4 years ago
by
Tobias Ørstad
Browse files
Options
Downloads
Patches
Plain Diff
Complete boundary value testing
parent
fb276ad4
No related branches found
Branches containing commit
No related tags found
4 merge requests
!18
Dev
,
!15
Dev
,
!12
Dev
,
!11
Boundarytests
Pipeline
#113904
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/secfit/users/tests.py
+5
-5
5 additions, 5 deletions
backend/secfit/users/tests.py
backend/secfit/workouts/tests.py
+197
-1
197 additions, 1 deletion
backend/secfit/workouts/tests.py
with
202 additions
and
6 deletions
backend/secfit/users/tests.py
+
5
−
5
View file @
ff17385c
...
...
@@ -68,7 +68,7 @@ class RegisterEmailBoundaryTestCase(TestCase):
class
RegisterEmailBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1
"
,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
client
=
APIClient
()
def
test_blank_password
(
self
):
...
...
@@ -134,7 +134,7 @@ class RegisterEmailBoundaryTestCase(TestCase):
class
RegisterPhonenumberBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1
"
,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
client
=
APIClient
()
def
test_blank_number
(
self
):
...
...
@@ -181,7 +181,7 @@ class RegisterPhonenumberBoundaryTestCase(TestCase):
class
RegisterCountryBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1
"
,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
""
,
"
street_address
"
:
""
}
'
)
self
.
client
=
APIClient
()
def
test_blank_country
(
self
):
...
...
@@ -202,7 +202,7 @@ class RegisterCountryBoundaryTestCase(TestCase):
class
RegisterCityBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
"
Hello
"
,
"
street_address
"
:
""
}
'
)
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1
"
,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
"
Hello
"
,
"
street_address
"
:
""
}
'
)
self
.
client
=
APIClient
()
def
test_blank_city
(
self
):
...
...
@@ -219,7 +219,7 @@ class RegisterCityBoundaryTestCase(TestCase):
class
RegisterCityBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
"
Hello
"
,
"
street_address
"
:
"
22
"
}
'
)
self
.
request
=
json
.
loads
(
'
{
"
username
"
:
"
bob
"
,
"
password
"
:
"
Heihei1
"
,
"
password1
"
:
"
Heihei1
"
,
"
athletes
"
: [],
"
email
"
:
"
bob@bob.no
"
,
"
coach_files
"
: [],
"
athlete_files
"
: [],
"
workouts
"
:[],
"
phone_number
"
:
"
12345678
"
,
"
country
"
:
"
hoh
"
,
"
city
"
:
"
Hello
"
,
"
street_address
"
:
"
22
"
}
'
)
self
.
client
=
APIClient
()
def
test_blank_adress
(
self
):
...
...
This diff is collapsed.
Click to expand it.
backend/secfit/workouts/tests.py
+
197
−
1
View file @
ff17385c
...
...
@@ -4,8 +4,204 @@ Tests for the workouts application.
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
,
APIClient
import
json
from
workouts.models
import
Workout
from
users.models
import
User
from
workouts.models
import
Exercise
# Create your tests here.
# Create your tests here.
class
WorkoutsNameBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_name
(
self
):
self
.
request
[
"
name
"
]
=
""
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_valid_name
(
self
):
self
.
request
[
"
name
"
]
=
"
plank
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
def
test_special_name
(
self
):
self
.
request
[
"
name
"
]
=
"
Pla’nk #3
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
class
WorkoutsDateBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_date
(
self
):
self
.
request
[
"
date
"
]
=
""
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_date
(
self
):
self
.
request
[
"
date
"
]
=
"
2021-22-20T13:29:00.000Z
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_valid_date
(
self
):
self
.
request
[
"
date
"
]
=
"
2021-03-20T13:29:00.000Z
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
class
WorkoutsNotesBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_notes
(
self
):
self
.
request
[
"
notes
"
]
=
""
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
def
test_valid_notes
(
self
):
self
.
request
[
"
notes
"
]
=
"
normal plank
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
def
test_special_notes
(
self
):
self
.
request
[
"
notes
"
]
=
"
Pla’nk #3
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
class
WorkoutsVisibilityBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
""
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
"
PA
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_valid_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
"
PU
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
class
WorkoutsExerciseBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
""
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
"
PA
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_valid_visibility
(
self
):
self
.
request
[
"
visibility
"
]
=
"
PU
"
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
class
WorkoutsExerciseBoundaryTestCase
(
TestCase
):
def
setUp
(
self
):
User
.
objects
.
create
(
id
=
"
1
"
,
username
=
"
Bill
"
,
password
=
"
secret
"
)
self
.
user_1
=
User
.
objects
.
get
(
id
=
"
1
"
)
self
.
client
=
APIClient
()
self
.
client
.
force_authenticate
(
user
=
self
.
user_1
)
self
.
client
.
post
(
'
http://testserver/api/exercises/
'
,
json
.
dumps
({
"
name
"
:
"
test
"
,
"
description
"
:
"
test
"
,
"
unit
"
:
"
kilos
"
}),
content_type
=
'
application/json
'
)
self
.
exercise_object
=
{
"
exercise
"
:
"
http://testserver/api/exercises/1/
"
,
"
number
"
:
"
1
"
,
"
sets
"
:
"
1
"
}
self
.
request
=
json
.
loads
(
'
{
"
name
"
:
"
bob
"
,
"
date
"
:
"
2021-03-20T13:29:00.000Z
"
,
"
notes
"
:
"
jj
"
,
"
visibility
"
:
"
PU
"
,
"
exercise_instances
"
: [],
"
filename
"
: []}
'
)
def
test_blank_exercise_instances
(
self
):
self
.
request
[
"
exercise_instances
"
]
=
[]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
def
test_invalid_exercise_instances
(
self
):
self
.
request
[
"
exercise_instances
"
]
=
[
"
geir
"
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_exercise
(
self
):
self
.
exercise_object
[
"
exercise
"
]
=
"
http://testserver/api/exercises/4
"
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_valid_exercise
(
self
):
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
201
)
def
test_blank_exercise
(
self
):
self
.
exercise_object
[
"
exercise
"
]
=
""
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_blank_number
(
self
):
self
.
exercise_object
[
"
sets
"
]
=
""
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_blank_sets
(
self
):
self
.
exercise_object
[
"
number
"
]
=
""
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_number
(
self
):
self
.
exercise_object
[
"
number
"
]
=
"
g
"
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_invalid_sets
(
self
):
self
.
exercise_object
[
"
sets
"
]
=
"
g
"
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
def
test_negative_sets
(
self
):
self
.
exercise_object
[
"
sets
"
]
=
"
-1
"
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
\ No newline at end of file
def
test_negative_number
(
self
):
self
.
exercise_object
[
"
number
"
]
=
"
-1
"
self
.
request
[
"
exercise_instances
"
]
=
[
self
.
exercise_object
]
request
=
self
.
client
.
post
(
'
http://testserver/api/workouts/
'
,
json
.
dumps
(
self
.
request
),
content_type
=
'
application/json
'
)
self
.
assertEquals
(
request
.
status_code
,
400
)
\ No newline at end of file
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