Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDT4242-group15
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
Vegard Murvold Sporstøl
TDT4242-group15
Commits
88e5fa71
Commit
88e5fa71
authored
4 years ago
by
Vegard Murvold Sporstøl
Browse files
Options
Downloads
Patches
Plain Diff
work on tests
parent
7d1fc7e0
No related branches found
No related tags found
1 merge request
!7
Task3
Pipeline
#113681
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
+23
-18
23 additions, 18 deletions
backend/secfit/users/tests.py
backend/secfit/workouts/tests.py
+23
-6
23 additions, 6 deletions
backend/secfit/workouts/tests.py
with
46 additions
and
24 deletions
backend/secfit/users/tests.py
+
23
−
18
View file @
88e5fa71
import
json
from
django.contrib.auth.models
import
User
from
django.urls
import
reverse
from
rest_framework
import
status
from
rest_framework.authtoken.models
import
Token
from
rest_framework.test
import
APITestCase
from
users.serializers
import
UserSerializer
from
users.models
import
User
from
django.test
import
TestCase
# Tests new registration, boundary values and 2-way domain
class
RegistrationTestCase
(
APITestCase
):
def
test_registration
(
self
):
data
=
{
"
username
"
:
"
testcase
"
,
"
email
"
:
"
test@test.no
"
,
"
password
"
:
"
strong_pwd
"
,
"
password1
"
:
"
strong_pwd
"
,
"
phone_number
"
:
"
95080764
"
,
"
country
"
:
"
Norway
"
,
"
city
"
:
"
Trondheim
"
,
"
street_address
"
:
"
Tors Veg 11C
"
}
def
test_boundaryValuesOfRegistrationInvalid
(
self
):
data
=
{
"
username
"
:
"
test
"
,
"
email
"
:
""
,
"
password
"
:
""
,
"
password1
"
:
""
,
"
phone_number
"
:
""
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
response
=
self
.
client
.
post
(
"
/api/users/
"
,
data
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
#should fail at blank pwd
data
=
{
"
username
"
:
""
,
"
email
"
:
""
,
"
password
"
:
"
1
"
,
"
password1
"
:
"
1
"
,
"
phone_number
"
:
""
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
response
=
self
.
client
.
post
(
"
/api/users/
"
,
data
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
#should fail at blank username
# Seem to be no upper value and no restrictions to the other fields
def
test_boundaryValuesOfRegistration
(
self
):
"
Test boudary values of signup
"
def
test_boundaryValuesOfRegistrationValid
(
self
):
data
=
{
"
username
"
:
"
t
"
,
"
email
"
:
""
,
"
password
"
:
"
1
"
,
"
password1
"
:
"
1
"
,
"
phone_number
"
:
""
,
"
country
"
:
""
,
"
city
"
:
""
,
"
street_address
"
:
""
}
response
=
self
.
client
.
post
(
"
/api/users/
"
,
data
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
#should work at one char pwd and username
def
test_domainRegistration
(
self
):
"
2-way domain tests to test the register page
"
# Tests new functionality in UC-2
class
Statistics
(
APITestCase
):
def
test_renderStatistics
(
self
):
...
...
This diff is collapsed.
Click to expand it.
backend/secfit/workouts/tests.py
+
23
−
6
View file @
88e5fa71
...
...
@@ -7,18 +7,35 @@ from rest_framework.authtoken.models import Token
from
rest_framework.test
import
APITestCase
from
users.serializers
import
UserSerializer
from
users.models
import
User
from
workouts.serializers
import
WorkoutSerializer
from
workouts.models
import
Workout
from
django.test
import
TestCase
# Tests new workout and boundary values
class
NewWorkoutTestCase
(
APITestCase
):
# Følger denne: https://www.youtube.com/watch?v=1FqxfnlQPi8&ab_channel=pymike00
# men skjønner ikke helt feilmeldinga som kommer nå, setup funker ikke
def
setUp
(
self
):
self
.
user
=
User
.
objects
.
create_user
(
username
=
"
test
"
,
password
=
"
strong_pwd
"
)
self
.
token
=
Token
.
object
.
create
(
user
=
self
.
user
)
self
.
api_authentication
()
def
api_authentication
(
self
):
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
"
Token
"
+
self
.
token
.
key
)
def
test_newWorkoutRegistration
(
self
):
"
Test registering a new workout
"
data
=
{
"
name
"
:
"
test
"
,
"
date
"
:
"
2019-09-25 06:00
"
,
"
notes
"
:
"
test
"
,
"
owner
"
:
""
,
"
visibility
"
:
"
Public
"
}
response
=
self
.
client
.
post
(
"
/api/workouts/
"
,
data
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
#should work
def
test_boundaryValuesOfNewWorkout
(
self
):
"
test boundary values of new workout
"
# Tests FR5
class
WorkoutDetails
(
APITestCase
):
def
test_viewDetails
(
self
):
"
Test that user can view all details
"
...
...
@@ -29,7 +46,7 @@ class WorkoutDetails(APITestCase):
def
test_viewComments
(
self
):
"
Test that user can view all comments
"
# Tests new functionality in UC-3 and UC-4
class
Categories
(
APITestCase
):
def
test_categorizeExercise
(
self
):
"
test that categorizing exercise works
"
...
...
@@ -37,7 +54,7 @@ class Categories(APITestCase):
def
test_sortExercise
(
self
):
"
test that sorting exercise works
"
# Tests new functionality in UC-1
class
NewWorkoutAsCoach
(
APITestCase
):
def
test_createWorkoutAsCoach
(
self
):
"
Check that a workout can be created as a coach
"
\ 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