Add a new regression test: test_lecturer_can_add_student_numbers

Hui-Organize
Lan Hui 2024-09-26 18:14:37 +08:00
parent 1ed7e2e394
commit 39c14f7425
1 changed files with 44 additions and 8 deletions

View File

@ -12,7 +12,7 @@ def test_admin_can_create_lecturer_account(driver, url, admin_username, admin_pa
login(driver, url, admin_username, admin_password)
# Create a Lecturer account for Mr Lan (mrlan@qq.com, password [123Abc!])
tab = driver.find_element(By.ID, 'tab_ins_accounts')
tab = driver.find_element(By.ID, 'tab_ins_accounts')
tab.click()
elem = driver.find_element(By.NAME, 'fullname')
elem.send_keys('Mr Lan')
@ -24,7 +24,7 @@ def test_admin_can_create_lecturer_account(driver, url, admin_username, admin_pa
radio_button.click()
button = driver.find_element(By.NAME, 'create_btn')
button.click()
# Log out Admin account
logout(driver)
@ -63,7 +63,7 @@ def test_lecturer_can_create_course(driver, url, restore_database):
def test_lecturer_can_post_assignment(driver, url, restore_database):
# Lecturer mrlan@qq.com logs in
# Lecturer lanhui@qq.com logs in
driver.maximize_window()
login(driver, url, 'lanhui@qq.com', '123')
@ -92,11 +92,47 @@ def test_lecturer_can_post_assignment(driver, url, restore_database):
assert 'Deadline: 2024-12-30' in elem.text
@pytest.mark.skip()
def test_lecturer_can_add_student_numbers():
# Lecturer mrlan@qq.com logs in
# Add 6 ASE student numbers
assert True
def test_lecturer_can_add_student_numbers(driver, url, restore_database):
# Lecturer lanhui@qq.com logs in
driver.maximize_window()
login(driver, url, 'lanhui@qq.com', '123')
# Add ASE student numbers
student_numbers = '''
202420781739
202420781740
202420781741
202420781742
202420781743
202420781745
202420581366
202420581368
202420581369
202420581370
202420581372
202420581373
202420581374
202420581376
202420581378
202420581381
'''
elem = driver.find_element(By.ID, 'admin_tab')
elem.click()
elem = driver.find_element(By.NAME, 'users')
elem.send_keys(student_numbers)
elem = driver.find_element(By.ID, 'register_btn')
elem.click()
elems = driver.find_elements(By.CSS_SELECTOR, 'p')
added = 0
student_lst = [number.strip() for number in student_numbers.strip().split('\n')]
print(student_lst)
for student_no in student_lst:
for elem in elems:
if student_no in elem.text and 'added' in elem.text:
added += 1
break
assert added == len(student_lst)
@pytest.mark.skip()