Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Jan Maximilian Michal
grady
Commits
743563f5
Commit
743563f5
authored
5 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
Added test case
parent
28235ba0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
functional_tests/test_feedback_creation.py
+2
-8
2 additions, 8 deletions
functional_tests/test_feedback_creation.py
functional_tests/test_feedback_update.py
+85
-0
85 additions, 0 deletions
functional_tests/test_feedback_update.py
functional_tests/util.py
+12
-0
12 additions, 0 deletions
functional_tests/util.py
with
99 additions
and
8 deletions
functional_tests/test_feedback_creation.py
+
2
−
8
View file @
743563f5
...
...
@@ -6,7 +6,7 @@ from selenium.webdriver.support import expected_conditions as ec
from
core.models
import
UserAccount
,
Submission
,
FeedbackComment
from
functional_tests.util
import
(
login
,
create_browser
,
reset_browser_after_test
,
go_to_subscription
,
wait_until_code_changes
,
reconstruct_submission_code
)
reconstruct_submission_code
,
correct_some_submission
)
from
util
import
factory_boys
as
fact
...
...
@@ -93,13 +93,7 @@ class UntestedParent:
def
test_can_give_max_score
(
self
):
self
.
_login
()
go_to_subscription
(
self
)
code
=
reconstruct_submission_code
(
self
)
self
.
browser
.
find_element_by_id
(
'
score-full
'
).
click
()
submit_btn
=
self
.
browser
.
find_element_by_id
(
'
submit-feedback
'
)
submit_btn
.
click
()
WebDriverWait
(
self
.
browser
,
10
).
until
(
wait_until_code_changes
(
self
,
code
)
)
code
=
correct_some_submission
()
submission_for_code
=
Submission
.
objects
.
get
(
text
=
code
)
self
.
assertEqual
(
self
.
sub_type
.
full_score
,
submission_for_code
.
feedback
.
score
)
...
...
This diff is collapsed.
Click to expand it.
functional_tests/test_feedback_update.py
0 → 100644
+
85
−
0
View file @
743563f5
from
django.test
import
LiveServerTestCase
from
selenium
import
webdriver
from
selenium.webdriver
import
ActionChains
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions
as
ec
from
core.models
import
FeedbackLabel
from
functional_tests.util
import
(
login
,
create_browser
,
reset_browser_after_test
,
query_returns_object
,
go_to_subscription
,
reconstruct_submission_code
,
wait_until_code_changes
,
correct_some_submission
)
from
util
import
factory_boys
as
fact
import
time
class
TestFeedbackUpdate
(
LiveServerTestCase
):
browser
:
webdriver
.
Firefox
=
None
username
=
None
password
=
None
role
=
None
@classmethod
def
setUpClass
(
cls
):
super
().
setUpClass
()
cls
.
browser
=
create_browser
()
@classmethod
def
tearDownClass
(
cls
):
super
().
tearDownClass
()
cls
.
browser
.
quit
()
def
setUp
(
self
):
super
().
setUp
()
self
.
username
=
'
tut
'
self
.
password
=
'
p
'
fact
.
UserAccountFactory
(
username
=
self
.
username
,
password
=
self
.
password
,
)
self
.
sub_type
=
fact
.
SubmissionTypeFactory
.
create
()
fact
.
SubmissionFactory
.
create_batch
(
2
,
type
=
self
.
sub_type
)
def
_login
(
self
):
login
(
self
.
browser
,
self
.
live_server_url
,
self
.
username
,
self
.
password
)
def
test_updating_own_feedback_doesnt_invalidate_other_tutors_assignment
(
self
):
self
.
_login
()
code
=
correct_some_submission
(
self
)
first_tab
=
self
.
browser
.
current_window_handle
# body = self.browser.find_element_by_tag_name('body')
# body.send_keys(Keys.LEFT_CONTROL + 't')
self
.
browser
.
execute_script
(
'
window.open()
'
)
self
.
browser
.
switch_to
.
window
(
self
.
browser
.
window_handles
[
-
1
])
second_tab
=
self
.
browser
.
current_window_handle
self
.
browser
.
execute_script
(
"
window.sessionStorage.clear()
"
)
self
.
browser
.
get
(
self
.
live_server_url
)
username
=
'
other_tut
'
password
=
'
p
'
fact
.
UserAccountFactory
(
username
=
username
,
password
=
password
)
login
(
self
.
browser
,
self
.
live_server_url
,
username
,
password
)
go_to_subscription
(
self
,
stage
=
'
validate
'
)
other_code
=
reconstruct_submission_code
(
self
)
self
.
assertEqual
(
code
,
other_code
,
"
Code for validation submissions is different than initial
"
)
self
.
browser
.
switch_to
.
window
(
first_tab
)
self
.
browser
.
find_element_by_partial_link_text
(
'
Feedback History
'
).
click
()
# time.sleep(3)
feedback_entry
=
self
.
browser
.
find_element_by_class_name
(
'
feedback-row
'
)
ActionChains
(
self
.
browser
).
move_to_element
(
feedback_entry
).
click
().
perform
()
self
.
browser
.
find_element_by_id
(
'
submit-feedback
'
).
click
()
self
.
browser
.
switch_to
.
window
(
second_tab
)
self
.
browser
.
find_element_by_id
(
'
submit-feedback
'
).
click
()
WebDriverWait
(
self
.
browser
,
10
).
until
(
ec
.
url_contains
(
'
ended
'
),
'
Browser is not on Subscription ended site, therefore Feedback could not be submitted
'
)
This diff is collapsed.
Click to expand it.
functional_tests/util.py
+
12
−
0
View file @
743563f5
...
...
@@ -106,6 +106,18 @@ def go_to_subscription(test_class_instance, stage='initial', sub_type=None):
WebDriverWait
(
test_class_instance
.
browser
,
10
).
until
(
ec
.
url_contains
(
'
subscription
'
))
def
correct_some_submission
(
test_class_instance
):
go_to_subscription
(
test_class_instance
)
code
=
reconstruct_submission_code
(
test_class_instance
)
test_class_instance
.
browser
.
find_element_by_id
(
'
score-full
'
).
click
()
submit_btn
=
test_class_instance
.
browser
.
find_element_by_id
(
'
submit-feedback
'
)
submit_btn
.
click
()
WebDriverWait
(
test_class_instance
.
browser
,
10
).
until
(
wait_until_code_changes
(
test_class_instance
,
code
)
)
return
code
def
reconstruct_submission_code
(
test_class_instance
):
sub_table
=
test_class_instance
.
browser
.
find_element_by_class_name
(
'
submission-table
'
)
lines
=
sub_table
.
find_elements_by_tag_name
(
'
tr
'
)
...
...
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