1- import  unittest 
2- 
31import  pytest 
4- from   ddt   import   data ,  ddt 
2+ 
53from  selenium .webdriver .common .by  import  By 
64
75from  JDI .core .settings .jdi_settings  import  JDISettings 
108from  tests .jdi_uitests_webtests .main .enums .preconditions  import  Preconditions 
119from  tests .jdi_uitests_webtests .main .page_objects .epam_jdi_site  import  EpamJDISite 
1210from  tests .jdi_uitests_webtests .main .utils .common_action_data  import  CommonActionsData 
13- from  tests .jdi_uitests_webtests .test .init_tests  import  InitTests 
1411
1512FIRE_MSG  =  "Fire: condition changed to true" 
1613WATER_MSG  =  "Water: condition changed to true" 
1714
1815
16+ @pytest .fixture  
17+ def  check_list_setup (site ):
18+  Preconditions .METALS_AND_COLORS_PAGE .is_in_state ()
19+ 
20+ 
1921@pytest .mark .web  
20- @ddt  
21- class  CheckListTests (InitTests ):
22+ class  TestCheckList :
2223 nature_options  =  ["Water" , "Earth" , "Wind" , "Fire" ]
2324 all_values  =  "Water, Earth, Wind, Fire" 
2425
2526 check_list  =  EpamJDISite .metals_colors_page .nature_check_list 
2627
27-  def  setUp (self ):
28-  super (CheckListTests , self ).setUp (self .id ().split ("." )[- 1 ])
29-  Preconditions .METALS_AND_COLORS_PAGE .is_in_state ()
30- 
31-  @data ("Fire" , 4 , Nature .FIRE ) 
32-  def  test_select (self , value ):
28+  @pytest .mark .parametrize ("value" , ("Fire" , 4 , Nature .FIRE )) 
29+  def  test_select (self , check_list_setup , value ):
3330 self .check_list .select (value )
3431 CommonActionsData .check_action (FIRE_MSG )
3532
36-  def  test_select_2_string (self ):
33+  def  test_select_2_string (self ,  check_list_setup ):
3734 self .check_list .select ("Water" , "Fire" )
3835 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
3936 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
4037
41-  def  test_select_2_index (self ):
38+  def  test_select_2_index (self ,  check_list_setup ):
4239 self .check_list .select (1 , 4 )
4340 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
4441 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
4542
46-  def  test_select_2_enum (self ):
43+  def  test_select_2_enum (self ,  check_list_setup ):
4744 self .check_list .select (Nature .WATER , Nature .FIRE )
4845 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
4946 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
5047
51-  @data ( " Fire"4 , Nature .FIRE ) 
52-  def  test_check (self , value ):
48+  @pytest . mark . parametrize ( "value" , ( " Fire"4 , Nature .FIRE ) ) 
49+  def  test_check (self , check_list_setup ,  value ):
5350 self .check_list .check (value )
5451 CommonActionsData .check_action (FIRE_MSG )
5552
56-  def  test_check_2_string (self ):
53+  def  test_check_2_string (self ,  check_list_setup ):
5754 self .check_list .check ("Water" , "Fire" )
5855 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
5956 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
6057
61-  def  test_check_2_index (self ):
58+  def  test_check_2_index (self ,  check_list_setup ):
6259 self .check_list .check (1 , 4 )
6360 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
6461 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
6562
66-  def  test_check_2_enum (self ):
63+  def  test_check_2_enum (self ,  check_list_setup ):
6764 self .check_list .check (Nature .WATER , Nature .FIRE )
6865 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
6966 CommonActionsData .check_action (WATER_MSG , line_number = 1 )
7067
71-  def  test_select_all (self ):
68+  def  test_select_all (self ,  check_list_setup ):
7269 self .check_list .select_all ()
7370 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
7471 CommonActionsData .check_action ("Wind: condition changed to true" , line_number = 1 )
7572 CommonActionsData .check_action ("Earth: condition changed to true" , line_number = 2 )
7673 CommonActionsData .check_action (WATER_MSG , line_number = 3 )
7774 self .check_all_checked ()
7875
79-  def  test_check_all (self ):
76+  def  test_check_all (self ,  check_list_setup ):
8077 self .check_list .check_all ()
8178 CommonActionsData .check_action (FIRE_MSG , line_number = 0 )
8279 CommonActionsData .check_action ("Wind: condition changed to true" , line_number = 1 )
8380 CommonActionsData .check_action ("Earth: condition changed to true" , line_number = 2 )
8481 CommonActionsData .check_action (WATER_MSG , line_number = 3 )
8582 self .check_all_checked ()
8683
87-  def  test_clear_all (self ):
84+  def  test_clear_all (self ,  check_list_setup ):
8885 self .check_list .check_all ()
8986 self .check_all_checked ()
9087 self .check_list .clear ()
9188 self .check_all_unchecked ()
9289
93-  def  test_uncheck_all (self ):
90+  def  test_uncheck_all (self ,  check_list_setup ):
9491 self .check_list .check_all ()
9592 self .check_all_checked ()
9693 self .check_list .uncheck_all ()
9794 self .check_all_unchecked ()
9895
99-  def  test_get_options (self ):
96+  def  test_get_options (self ,  check_list_setup ):
10097 Assert .assert_equal (self .check_list .get_options (), self .nature_options )
10198
102-  def  test_get_names (self ):
99+  def  test_get_names (self ,  check_list_setup ):
103100 Assert .assert_equal (self .check_list .get_names (), self .nature_options )
104101
105-  def  test_get_values (self ):
102+  def  test_get_values (self ,  check_list_setup ):
106103 Assert .assert_equal (self .check_list .get_values (), self .nature_options )
107104
108-  def  test_get_options_as_text (self ):
105+  def  test_get_options_as_text (self ,  check_list_setup ):
109106 Assert .assert_equal (self .check_list .get_options_as_text (), self .all_values )
110107
111-  def  test_set_value (self ):
108+  def  test_set_value (self ,  check_list_setup ):
112109 self .check_list .set_value ("Fire" )
113110 CommonActionsData .check_action (FIRE_MSG )
114111
115-  def  test_get_name (self ):
112+  def  test_get_name (self ,  check_list_setup ):
116113 Assert .assert_equal (self .check_list .get_name (), "nature_check_list" )
117114
118-  def  test_are_selected (self ):
115+  def  test_are_selected (self ,  check_list_setup ):
119116 Assert .assert_equal (self .check_list .are_selected (), [])
120117
121-  def  test_are_deselected (self ):
118+  def  test_are_deselected (self ,  check_list_setup ):
122119 Assert .assert_equal (self .check_list .are_deselected (), self .nature_options )
123120
124-  def  test_get_value (self ):
121+  def  test_get_value (self ,  check_list_setup ):
125122 Assert .assert_equal (self .check_list .get_value (), None )
126123
127124 def  check_all_checked (self ):
@@ -135,7 +132,3 @@ def check_all_unchecked(self):
135132 els  =  driver .find_elements (By .CSS_SELECTOR , value = "#elements-checklist input" )
136133 for  el  in  els :
137134 Assert .assert_true (el .get_attribute ("checked" ) in  ["false" , None ])
138- 
139- 
140- if  __name__  ==  "__main__" :
141-  unittest .main ()
0 commit comments