77
88logger = logging .getLogger (__name__ )
99
10- # Define step-wise test actions for Golden Path
11- golden_path_steps = [
12- ("01. Validate home page is loaded" , lambda home : home .validate_home_page ()),
13- ("02. Validate Upload of other than SQL files" , lambda home : home .upload_unsupported_files ()),
14- ("03. Validate Upload input files for SQL only" , lambda home : home .upload_files ()),
15- ("04. Validate translation process for uploaded files" , lambda home : _timed_translation (home )),
16- ("05. Check batch history" , lambda home : home .validate_batch_history ()),
17- ("06. Download all files and return home" , lambda home : home .validate_download_files ()),
18- ]
19-
2010
2111def _timed_translation (home ):
2212 start = time .time ()
@@ -25,22 +15,228 @@ def _timed_translation(home):
2515 logger .info (f"Translation process for uploaded files took { end - start :.2f} seconds" )
2616
2717
28- @pytest .mark .parametrize ( "description, action" , golden_path_steps , ids = [ desc for desc , _ in golden_path_steps ])
29- def test_codegen_golden_path (login_logout , description , action , request ):
18+ @pytest .mark .gp
19+ def test_codegen_golden_path (login_logout , request ):
3020 """
21+ CodeMod- Validate Golden path works as expected
22+
3123 Executes golden path test steps for Modernize Your Code Accelerator with detailed logging.
3224 """
33- request .node ._nodeid = description # To improve test output readability
25+ request .node ._nodeid = "Modernize your code- Validate Golden path works as expected"
26+
27+ page = login_logout
28+ home = HomePage (page )
29+
30+ # Define step-wise test actions for Golden Path
31+ golden_path_steps = [
32+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
33+ ("02. Validate Upload of other than SQL files" , lambda : home .upload_unsupported_files ()),
34+ ("03. Validate Upload input files for SQL only" , lambda : home .upload_files ()),
35+ ("04. Validate translation process for uploaded files" , lambda : _timed_translation (home )),
36+ ("05. Check batch history" , lambda : home .validate_batch_history ()),
37+ ("06. Download all files" , lambda : home .validate_download_files ()),
38+ ("07. Return to home page" , lambda : home .return_to_home_page ()),
39+ ]
40+
41+ # Execute all steps sequentially
42+ for description , action in golden_path_steps :
43+ logger .info (f"Running test step: { description } " )
44+ try :
45+ action ()
46+ logger .info (f"Step passed: { description } " )
47+ except Exception :
48+ logger .error (f"Step failed: { description } " , exc_info = True )
49+ raise
50+
51+
52+
53+ def test_upload_all_files_and_navigate_home (login_logout , request ):
54+ """
55+ CodeMod- Validate upload all files, verify count, and navigate to home page
56+
57+ Test case that uploads all files from testdata folder, validates the uploaded
58+ files count is 20, and navigates back to home page.
59+ """
60+ request .node ._nodeid = "Modernize your code - Validate Files uploading and its limit."
61+
62+ page = login_logout
63+ home = HomePage (page )
64+
65+ # Define test steps
66+ test_steps = [
67+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
68+ ("02. Upload all files from testdata folder" , lambda : home .upload_all_files ()),
69+ ("03. Validate uploaded files count equals 20" , lambda : home .validate_uploaded_files_count ()),
70+ ("04. Navigate back to home page" , lambda : home .navigate_to_home_page ()),
71+ ]
72+
73+ # Execute all steps sequentially with logging
74+ for description , action in test_steps :
75+ logger .info (f"Running test step: { description } " )
76+ try :
77+ action ()
78+ logger .info (f"Step passed: { description } " )
79+ except Exception :
80+ logger .error (f"Step failed: { description } " , exc_info = True )
81+ raise
82+
83+ def test_translate_and_download_files (login_logout , request ):
84+ """
85+ Modernize your code - Translating the files and downloading files
86+
87+ Test case that executes the complete translation workflow: upload files,
88+ translate them, and download the results with detailed logging.
89+ """
90+ request .node ._nodeid = "Modernize your code - Translating the files and downloading files"
91+
92+ page = login_logout
93+ home = HomePage (page )
94+
95+ # Define step-wise test actions for translation and download workflow
96+ test_steps = [
97+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
98+ ("02. Validate Upload of other than SQL files" , lambda : home .upload_unsupported_files ()),
99+ ("03. Validate Upload input files for SQL only" , lambda : home .upload_files ()),
100+ ("04. Validate translation process for uploaded files" , lambda : _timed_translation (home )),
101+ ("05. Check batch history" , lambda : home .validate_batch_history ()),
102+ ("06. Download all files" , lambda : home .validate_download_files ()),
103+ ("07. Return to home page" , lambda : home .click_logo_and_validate_home ()),
104+ ]
34105
106+ # Execute all steps sequentially with detailed logging
107+ for description , action in test_steps :
108+ logger .info (f"Running test step: { description } " )
109+ try :
110+ action ()
111+ logger .info (f"Step passed: { description } " )
112+ except Exception :
113+ logger .error (f"Step failed: { description } " , exc_info = True )
114+ raise
115+
116+
117+
118+ def test_upload_remove_files_and_cancel (login_logout , request ):
119+ """
120+ CodeMod- Validate upload files, remove files, and cancel upload
121+
122+ Test case that uploads 20 files from testdata folder, removes the first three files,
123+ validates the remaining count is 17, and then cancels the upload process.
124+ """
125+ request .node ._nodeid = "Modernize your code - Validate Single and Batch deletion of Files."
126+
127+ page = login_logout
128+ home = HomePage (page )
129+
130+ # Define test steps
131+ test_steps = [
132+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
133+ ("02. Upload all files from testdata folder (20 files max)" , lambda : home .upload_all_files ()),
134+ ("03. Validate uploaded files count equals 20" , lambda : home .validate_uploaded_files_count ()),
135+ ("04. Remove first three files and validate count equals 17" , lambda : home .remove_first_three_files_and_validate_count ()),
136+ ("05. Cancel upload and validate return to home page" , lambda : home .cancel_upload_and_validate_home ()),
137+ ]
138+
139+ # Execute all steps sequentially with logging
140+ for description , action in test_steps :
141+ logger .info (f"Running test step: { description } " )
142+ try :
143+ action ()
144+ logger .info (f"Step passed: { description } " )
145+ except Exception :
146+ logger .error (f"Step failed: { description } " , exc_info = True )
147+ raise
148+
149+
150+ def test_delete_batch_history (login_logout , request ):
151+ """
152+ CodeMod- Validate delete batch history functionality
153+
154+ Test case that executes the golden path flow (upload, translate, download) and then
155+ validates the deletion of the first batch history item.
156+ """
157+ request .node ._nodeid = "Modernize your code - Validate Batch history panel."
158+
159+ page = login_logout
160+ home = HomePage (page )
161+
162+ # Define test steps (golden path without return home + delete batch history)
163+ test_steps = [
164+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
165+ ("02. Validate Upload of other than SQL files" , lambda : home .upload_unsupported_files ()),
166+ ("03. Validate Upload input files for SQL only" , lambda : home .upload_files ()),
167+ ("04. Validate translation process for uploaded files" , lambda : _timed_translation (home )),
168+ ("05. Check batch history" , lambda : home .validate_batch_history ()),
169+ ("06. Download all files" , lambda : home .validate_download_files ()),
170+ ("07. Delete first batch history and validate count" , lambda : home .delete_first_batch_history_and_validate_count ())
171+ ]
172+
173+ # Execute all steps sequentially with logging
174+ for description , action in test_steps :
175+ logger .info (f"Running test step: { description } " )
176+ try :
177+ action ()
178+ logger .info (f"Step passed: { description } " )
179+ except Exception :
180+ logger .error (f"Step failed: { description } " , exc_info = True )
181+ raise
182+
183+
184+ def test_upload_unsupported_files_validation (login_logout , request ):
185+ """
186+ CodeMod- Validate unsupported files upload and validation
187+
188+ Test case that uploads all unsupported files from testdata/Unsupported_files folder
189+ and validates that translate button is disabled with detailed logging.
190+ """
191+ request .node ._nodeid = "Modernize your code - Validate Attempt to upload files with an unsupported extension"
192+
193+ page = login_logout
194+ home = HomePage (page )
195+
196+ # Define test steps
197+ test_steps = [
198+ ("01. Validate home page is loaded" , lambda : home .validate_home_page ()),
199+ ("02. Upload all unsupported files and validate translate button is disabled" , lambda : home .upload_all_unsupported_files_and_validate ()),
200+ ]
201+
202+ # Execute all steps sequentially with logging
203+ for description , action in test_steps :
204+ logger .info (f"Running test step: { description } " )
205+ try :
206+ action ()
207+ logger .info (f"Step passed: { description } " )
208+ except Exception :
209+ logger .error (f"Step failed: { description } " , exc_info = True )
210+ raise
211+
212+
213+
214+
215+ def test_upload_harmful_file_validation (login_logout , request ):
216+ """
217+ CodeMod- Validate harmful file upload and processing error
218+
219+ Test case that uploads harmful file from testdata/Harmful_file folder,
220+ starts translation, and validates error message and disabled download button.
221+ """
222+ request .node ._nodeid = "Modernize your code - Validate Attempt to upload malicious files"
223+
35224 page = login_logout
36225 home = HomePage (page )
37226
38- logger . info ( f"Running test step: { description } " )
39- try :
40- action ( home )
41- except Exception :
42- logger . error ( f"Step failed: { description } " , exc_info = True )
43- raise
227+ # Define test steps
228+ test_steps = [
229+ ( "01. Validate home page is loaded" , lambda : home . validate_home_page ()),
230+ ( "02. Upload harmful file, translate, and validate error handling" , lambda : home . upload_harmful_file_and_validate ()),
231+ ( "03. Return to home page " , lambda : home . return_to_home_page ()),
232+ ]
44233
45- # Optional reporting hook
46- request .node ._report_sections .append (("call" , "log" , f"Step passed: { description } " ))
234+ # Execute all steps sequentially with logging
235+ for description , action in test_steps :
236+ logger .info (f"Running test step: { description } " )
237+ try :
238+ action ()
239+ logger .info (f"Step passed: { description } " )
240+ except Exception :
241+ logger .error (f"Step failed: { description } " , exc_info = True )
242+ raise
0 commit comments