1212
1313from app .config import Config
1414
15-
16- def test_basic_training ():
15+ class TestBasicTraining :
1716 Config .init_config ('/usr/src/project/app_conf/testing.ini' )
1817
1918 chrome_options = Options ()
@@ -29,74 +28,72 @@ def test_basic_training():
2928
3029 chrome_options .add_experimental_option ('detach' , True )
3130
32-
3331 driver = Chrome (options = chrome_options )
3432 session = requests .Session ()
3533 sleep (5 )
3634
37- # Инициализация тестовой сессии
3835 driver .get ('http://web:5000/init/' )
3936
40- # Регистрация в системе
41- session .request ('POST' ,'http://web:5000/lti' , data = {
42- 'lis_person_name_full' : Config .c .testing .lis_person_name_full ,
43- 'ext_user_username' : Config .c .testing .session_id ,
44- 'custom_task_id' : Config .c .testing .custom_task_id ,
45- 'custom_task_description' : Config .c .testing .custom_task_description ,
46- 'custom_attempt_count' : Config .c .testing .custom_attempt_count ,
47- 'custom_required_points' : Config .c .testing .custom_required_points ,
48- 'custom_criteria_pack_id' : Config .c .testing .custom_criteria_pack_id ,
49- 'roles' : Config .c .testing .roles ,
50- 'lis_outcome_service_url' : Config .c .testing .lis_outcome_service_url ,
51- 'lis_result_sourcedid' : Config .c .testing .lis_result_source_did ,
52- 'oauth_consumer_key' : Config .c .testing .oauth_consumer_key ,
53- })
54-
55- # Загрузка презентации
56- driver .get ('http://web:5000/upload_presentation/' )
37+ def test_registration ( self ):
38+ self . session .request ('POST' ,'http://web:5000/lti' , data = {
39+ 'lis_person_name_full' : Config .c .testing .lis_person_name_full ,
40+ 'ext_user_username' : Config .c .testing .session_id ,
41+ 'custom_task_id' : Config .c .testing .custom_task_id ,
42+ 'custom_task_description' : Config .c .testing .custom_task_description ,
43+ 'custom_attempt_count' : Config .c .testing .custom_attempt_count ,
44+ 'custom_required_points' : Config .c .testing .custom_required_points ,
45+ 'custom_criteria_pack_id' : Config .c .testing .custom_criteria_pack_id ,
46+ 'roles' : Config .c .testing .roles ,
47+ 'lis_outcome_service_url' : Config .c .testing .lis_outcome_service_url ,
48+ 'lis_result_sourcedid' : Config .c .testing .lis_result_source_did ,
49+ 'oauth_consumer_key' : Config .c .testing .oauth_consumer_key ,
50+ })
51+
52+ def test_presentation_upload ( self ):
53+ self . driver .get ('http://web:5000/upload_presentation/' )
5754
58- file_input = WebDriverWait (driver , 20 ).until (EC .visibility_of_element_located ((By .CSS_SELECTOR , "input[type=file]" )))
59- file_input .send_keys (f'{ os .getcwd ()} /test_data/test_presentation_file_0.pdf' )
55+ file_input = WebDriverWait (self . driver , 20 ).until (EC .visibility_of_element_located ((By .CSS_SELECTOR , "input[type=file]" )))
56+ file_input .send_keys (f'{ os .getcwd ()} /test_data/test_presentation_file_0.pdf' )
6057
61- WebDriverWait (driver , 5 ).until (EC .element_to_be_clickable ((By .ID , "button-submit" ))).click ()
58+ WebDriverWait (self . driver , 5 ).until (EC .element_to_be_clickable ((By .ID , "button-submit" ))).click ()
6259
63- # Подготовка и начало записи
64- WebDriverWait (driver , 10 ).until (EC .element_to_be_clickable ((By .ID , "record" ))).click ()
60+ def test_record_preparation ( self ):
61+ WebDriverWait (self . driver , 10 ).until (EC .element_to_be_clickable ((By .ID , "record" ))).click ()
6562
66- WebDriverWait (driver , 10 ).until (EC .presence_of_element_located ((By .ID , "model-timer" )))
63+ WebDriverWait (self . driver , 10 ).until (EC .presence_of_element_located ((By .ID , "model-timer" )))
6764
68- WebDriverWait (driver , 10 ).until (EC .invisibility_of_element ((By .ID , "model-timer" )))
65+ WebDriverWait (self . driver , 10 ).until (EC .invisibility_of_element ((By .ID , "model-timer" )))
6966
70- sleep (5 )
67+ sleep (5 )
7168
72- # Взаимодействие с презентацией
73- WebDriverWait (driver , 10 ).until (EC .element_to_be_clickable ((By .ID , "next" ))).click ()
69+ def test_button_next ( self ):
70+ WebDriverWait (self . driver , 10 ).until (EC .element_to_be_clickable ((By .ID , "next" ))).click ()
7471
75- sleep (5 )
72+ sleep (5 )
7673
77- # Конец выступления
78- WebDriverWait (driver , 5 ).until (EC .element_to_be_clickable ((By .ID , "done" ))).click ()
74+ def test_training_session_end ( self ):
75+ WebDriverWait (self . driver , 5 ).until (EC .element_to_be_clickable ((By .ID , "done" ))).click ()
7976
80- WebDriverWait (driver , 5 ).until (lambda d : d .switch_to .alert ).accept ()
77+ WebDriverWait (self . driver , 5 ).until (lambda d : d .switch_to .alert ).accept ()
8178
82- sleep (5 )
79+ sleep (5 )
8380
84- # Ожидание результата тренировки
85- feedback_flag = False
86- step_count = 10
87- step = 10
81+ def test_training_feedback ( self ):
82+ feedback_flag = False
83+ step_count = 10
84+ step = 10
8885
89- for _ in range (step_count ):
90- driver .refresh ()
86+ for _ in range (step_count ):
87+ self . driver .refresh ()
9188
92- feedback_elements = driver .find_elements (By .ID , 'feedback' )
89+ feedback_elements = self . driver .find_elements (By .ID , 'feedback' )
9390
94- if feedback_elements and feedback_elements [0 ].text .startswith ('Оценка за тренировку' ):
95- feedback_flag = True
96- break
97-
98- sleep (step )
91+ if feedback_elements and feedback_elements [0 ].text .startswith ('Оценка за тренировку' ):
92+ feedback_flag = True
93+ break
94+
95+ sleep (step )
9996
100- driver .close ()
97+ self . driver .close ()
10198
102- assert feedback_flag , f"Проверка тренировки заняла более { step_count * step } секунд"
99+ assert feedback_flag , f"Проверка тренировки заняла более { step_count * step } секунд"
0 commit comments