Skip to content
Snippets Groups Projects
Commit 743563f5 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Added test case

parent 28235ba0
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
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'
)
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment