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

@ -63,7 +63,7 @@ def test_lecturer_can_create_course(driver, url, restore_database):
def test_lecturer_can_post_assignment(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() driver.maximize_window()
login(driver, url, 'lanhui@qq.com', '123') 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 assert 'Deadline: 2024-12-30' in elem.text
@pytest.mark.skip() def test_lecturer_can_add_student_numbers(driver, url, restore_database):
def test_lecturer_can_add_student_numbers(): # Lecturer lanhui@qq.com logs in
# Lecturer mrlan@qq.com logs in driver.maximize_window()
# Add 6 ASE student numbers login(driver, url, 'lanhui@qq.com', '123')
assert True
# 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() @pytest.mark.skip()