Skip to content
Snippets Groups Projects

Resolve "Updating own past feedback sets other tutors assignment to is_done=True"

2 files
+ 28
19
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -10,14 +10,17 @@ from functional_tests.util import login, create_browser, reset_browser_after_tes
from util import factory_boys as fact
def expect_file_to_be_present(path):
def expect_file_to_be_downloaded(path):
"""
Checks if a file has finished downloading by checking if a file exists at the path and
no accompanying `<path>.part` file.
:param path: path to check
:return:
"""
def condition(*args):
try:
with open(path):
pass
except FileNotFoundError:
return False
return True
file_present = Path.is_file(path)
partial_file_present = os.path.join(path, '.part')
return file_present and not partial_file_present
return condition
@@ -117,11 +120,14 @@ class ExportTestModal(LiveServerTestCase):
export_type_json.click()
data_export_btn = data_export_modal.find_element_by_id('export-data-download-btn')
data_export_btn.click()
WebDriverWait(self.browser, 10).until(expect_file_to_be_present(JSON_EXPORT_FILE))
with open(JSON_EXPORT_FILE) as f:
data = json.load(f)
self.assertEqual('B.Inf.4242 Test Module', data[0]['Exam'])
os.remove(JSON_EXPORT_FILE)
WebDriverWait(self.browser, 10).until(expect_file_to_be_downloaded(JSON_EXPORT_FILE))
try:
with open(JSON_EXPORT_FILE) as f:
data = json.load(f)
self.assertEqual('B.Inf.4242 Test Module', data[0]['Exam'])
except Exception as e:
os.remove(JSON_EXPORT_FILE)
raise e
def test_export_instance(self):
fact.SubmissionFactory()
@@ -130,8 +136,11 @@ class ExportTestModal(LiveServerTestCase):
self.browser.find_element_by_id('export-list1').click()
instance_export_modal = self.browser.find_element_by_id('instance-export-modal')
instance_export_modal.find_element_by_id('instance-export-dl').click()
WebDriverWait(self.browser, 10).until(expect_file_to_be_present(JSON_EXPORT_FILE))
with open(JSON_EXPORT_FILE) as f:
data = json.load(f)
self.assertEqual('B.Inf.4242 Test Module', data['examTypes'][0]['moduleReference'])
os.remove(JSON_EXPORT_FILE)
WebDriverWait(self.browser, 10).until(expect_file_to_be_downloaded(JSON_EXPORT_FILE))
try:
with open(JSON_EXPORT_FILE) as f:
data = json.load(f)
self.assertEqual('B.Inf.4242 Test Module', data['examTypes'][0]['moduleReference'])
except Exception as e:
os.remove(JSON_EXPORT_FILE)
raise e
Loading