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
877d6e88
Commit
877d6e88
authored
4 years ago
by
Haakon Gunleiksrud
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!22
parents
b5df6720
c2e2151a
No related branches found
Branches containing commit
No related tags found
2 merge requests
!24
Backendcommentssmells
,
!22
Dev
Pipeline
#126967
passed
4 years ago
Stage: test
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/secfit/workouts/seleniumLeaderboardSystemTest.py
+220
-2
220 additions, 2 deletions
backend/secfit/workouts/seleniumLeaderboardSystemTest.py
with
220 additions
and
2 deletions
backend/secfit/workouts/seleniumLeaderboardSystemTest.py
+
220
−
2
View file @
877d6e88
...
...
@@ -328,6 +328,8 @@ class TestExerciseLeaderboard(unittest.TestCase):
# Logs in user 5
self
.
login_user
(
self
.
__class__
.
uniqueUsername5
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
...
...
@@ -366,12 +368,14 @@ class TestExerciseLeaderboard(unittest.TestCase):
# Tests that when the user changes the visibility of a public workout to "coach", the score is decremented accordingly,
# (the leaderboard should be correct in regard to size, rank and entrants.)
def
test08_
coach
_workouts_made_
private
_decrement_leaderboard_score
(
self
):
def
test08_
public
_workouts_made_
coach
_decrement_leaderboard_score
(
self
):
driver
=
self
.
driver
# Logs in user 4
self
.
login_user
(
self
.
__class__
.
uniqueUsername4
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
...
...
@@ -387,7 +391,7 @@ class TestExerciseLeaderboard(unittest.TestCase):
editButton
.
click
()
time
.
sleep
(
1
)
# Changes the visiblity to
private
# Changes the visiblity to
coach
workoutVisibilityField
=
driver
.
find_element_by_id
(
"
inputVisibility
"
)
workoutVisibilityField
.
send_keys
(
"
CO
"
)
...
...
@@ -407,6 +411,8 @@ class TestExerciseLeaderboard(unittest.TestCase):
self
.
assert_leaderboard
(
expected_leaderboard
)
# Tests that when the several users have the same score they also have the same rank,
# (the leaderboard should be correct in regard to size, rank and entrants.)
def
test09_same_score_is_same_rank
(
self
):
driver
=
self
.
driver
...
...
@@ -446,6 +452,218 @@ class TestExerciseLeaderboard(unittest.TestCase):
self
.
assert_leaderboard
(
expected_leaderboard
)
# Tests that when the user changes the visibility of a private workout to "public", the score is incremented accordingly,
# (the leaderboard should be correct in regard to size, rank and entrants.)
def
test10_test_private_workout_made_public_increments_score
(
self
):
driver
=
self
.
driver
# Logs in user 6
self
.
login_user
(
self
.
__class__
.
uniqueUsername6
)
# Creates a new workout
self
.
register_workout_with_exercise
(
"
2
"
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
80
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# Find and clicks the button to go to the workouts page
workoutNavButton
=
driver
.
find_element_by_id
(
"
nav-workouts
"
)
workoutNavButton
.
click
()
time
.
sleep
(
0.5
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
time
.
sleep
(
1
)
# Views the workout
workout
=
driver
.
find_elements_by_css_selector
(
"
a.list-group-item
"
)[
-
1
]
workout
.
click
()
time
.
sleep
(
1
)
# Edits the workout
editButton
=
driver
.
find_element_by_id
(
"
btn-edit-workout
"
)
editButton
.
click
()
time
.
sleep
(
1
)
# Changes the visiblity to private
workoutVisibilityField
=
driver
.
find_element_by_id
(
"
inputVisibility
"
)
workoutVisibilityField
.
send_keys
(
"
PR
"
)
saveEditChangesButton
=
driver
.
find_element_by_id
(
"
btn-ok-workout
"
)
saveEditChangesButton
.
click
()
time
.
sleep
(
1
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# Find and clicks the button to go to the workouts page
workoutNavButton
=
driver
.
find_element_by_id
(
"
nav-workouts
"
)
workoutNavButton
.
click
()
time
.
sleep
(
0.5
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
time
.
sleep
(
1
)
# Views the workout
workout
=
driver
.
find_elements_by_css_selector
(
"
a.list-group-item
"
)[
-
1
]
workout
.
click
()
time
.
sleep
(
1
)
# Edits the workout
editButton
=
driver
.
find_element_by_id
(
"
btn-edit-workout
"
)
editButton
.
click
()
time
.
sleep
(
1
)
# Changes the visiblity to public
workoutVisibilityField
=
driver
.
find_element_by_id
(
"
inputVisibility
"
)
workoutVisibilityField
.
send_keys
(
"
PU
"
)
saveEditChangesButton
=
driver
.
find_element_by_id
(
"
btn-ok-workout
"
)
saveEditChangesButton
.
click
()
time
.
sleep
(
1
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
80
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# Tests that when the user changes the visibility of a coach workout to "public", the score is incremented accordingly,
# (the leaderboard should be correct in regard to size, rank and entrants.)
def
test11_test_coach_workout_made_public_increments_score
(
self
):
driver
=
self
.
driver
# Logs in user 6
self
.
login_user
(
self
.
__class__
.
uniqueUsername6
)
# Creates a new workout
self
.
register_workout_with_exercise
(
"
4
"
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
120
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# Find and clicks the button to go to the workouts page
workoutNavButton
=
driver
.
find_element_by_id
(
"
nav-workouts
"
)
workoutNavButton
.
click
()
time
.
sleep
(
0.5
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
time
.
sleep
(
1
)
# Views the workout
workout
=
driver
.
find_elements_by_css_selector
(
"
a.list-group-item
"
)[
-
1
]
workout
.
click
()
time
.
sleep
(
1
)
# Edits the workout
editButton
=
driver
.
find_element_by_id
(
"
btn-edit-workout
"
)
editButton
.
click
()
time
.
sleep
(
1
)
# Changes the visiblity to private
workoutVisibilityField
=
driver
.
find_element_by_id
(
"
inputVisibility
"
)
workoutVisibilityField
.
send_keys
(
"
CO
"
)
saveEditChangesButton
=
driver
.
find_element_by_id
(
"
btn-ok-workout
"
)
saveEditChangesButton
.
click
()
time
.
sleep
(
1
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
80
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# Find and clicks the button to go to the workouts page
workoutNavButton
=
driver
.
find_element_by_id
(
"
nav-workouts
"
)
workoutNavButton
.
click
()
time
.
sleep
(
0.5
)
self
.
scroll_down
()
# Finds and clicks the button that views the user's own workouts
myWorkoutsButton
=
driver
.
find_element_by_id
(
"
list-my-workouts-list
"
)
myWorkoutsButton
.
click
()
time
.
sleep
(
1
)
# Views the workout
workout
=
driver
.
find_elements_by_css_selector
(
"
a.list-group-item
"
)[
-
1
]
workout
.
click
()
time
.
sleep
(
1
)
# Edits the workout
editButton
=
driver
.
find_element_by_id
(
"
btn-edit-workout
"
)
editButton
.
click
()
time
.
sleep
(
1
)
# Changes the visiblity to public
workoutVisibilityField
=
driver
.
find_element_by_id
(
"
inputVisibility
"
)
workoutVisibilityField
.
send_keys
(
"
PU
"
)
saveEditChangesButton
=
driver
.
find_element_by_id
(
"
btn-ok-workout
"
)
saveEditChangesButton
.
click
()
time
.
sleep
(
1
)
# What we expect the leaderboard to be like now
expected_leaderboard
=
[
{
"
rank
"
:
"
1
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername6
,
"
score
"
:
"
120
"
},
{
"
rank
"
:
"
2
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername2
,
"
score
"
:
"
70
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername3
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
3
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername5
,
"
score
"
:
"
60
"
},
{
"
rank
"
:
"
5
"
,
"
username
"
:
self
.
__class__
.
uniqueUsername1
,
"
score
"
:
"
50
"
},
]
# Asserts that the observed leaderboard matches the expected leaderboard
self
.
assert_leaderboard
(
expected_leaderboard
)
# *Not a test*, just a cleanup that deletes the workout that was created during the other tests. Tried using
# tearDownClass, but that did not let me access the website
def
test99_cleanup
(
self
):
...
...
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