99from tabulate import tabulate
1010from datetime import datetime
1111
12- pytestmark = [pytest .mark .schema_validation ]
12+ pytestmark = [pytest .mark .schema_validation_tests , pytest . mark . ow_regression_lf ]
1313
1414
1515# Get the directory of the current test config file
2222 config_data_1 = json .loads (json_string )
2323
2424file_path2 = os .path .join (test_file_dir , 'master-config-2.json' )
25- with open (file_path , 'r' ) as file :
25+ with open (file_path2 , 'r' ) as file :
2626 json_string = file .read ()
2727 config_data_2 = json .loads (json_string )
2828
2929file_path3 = os .path .join (test_file_dir , 'master-config-3.json' )
30- with open (file_path , 'r' ) as file :
30+ with open (file_path3 , 'r' ) as file :
3131 json_string = file .read ()
3232 config_data_3 = json .loads (json_string )
3333
@@ -50,7 +50,6 @@ def get_github_file(url, path=None, commit_id=None):
5050 "wlan-ucentral-schema repo." )
5151 return response .text
5252
53-
5453def validate_schema_through_github (commit_id , path ):
5554 def get_commit_id (owner , repo , path = "" , headers = None ):
5655 if headers is None :
@@ -116,14 +115,24 @@ def generate_diff(wlan_ucentral_schema_url, latest_version_id, previous_version_
116115 allure .attach (updated_schema_pretty_json , name = f"NEW { path } :" )
117116
118117 if updated_schema_pretty_json == previous_schema_pretty_json :
119- logging .info (f"No changes found at { path } . Exiting." )
118+ logging .info (f"No changes were found at { path } . Exiting." )
119+ allure .attach (name = f"No changes found at { path } " , body = f"No changes were found at { path } . Exiting the test." )
120120 return None , None , None
121121 else :
122122 logging .info (f"Changes found at { path } . Proceeding with the comparison." )
123123 added_keys , removed_keys , changed_items = compare_dicts (json .loads (previous_schema_pretty_json ),
124124 json .loads (updated_schema_pretty_json ))
125125 return added_keys , removed_keys , changed_items
126126
127+ def convert_changed_items_to_vertical_table (changed_items ):
128+ formatted_rows = []
129+ for path , old , new in changed_items :
130+ formatted_rows .append (["Key Path" , path ])
131+ formatted_rows .append (["Old Value" , old ])
132+ formatted_rows .append (["New Value" , new ])
133+ formatted_rows .append (["" , "" ]) # Add blank line between entries
134+ return tabulate (formatted_rows , headers = ["Field" , "Content" ], tablefmt = "fancy_grid" )
135+
127136 if commit_id is None :
128137 logging .info ("Use --commit-id to the pass an old commit-id of tip/wlan-ucentral-schema repo. Skipping the test." )
129138 pytest .skip ("Use --commit-id to the pass an old commit-id of tip/wlan-ucentral-schema repo. Skipping the test." )
@@ -164,15 +173,17 @@ def generate_diff(wlan_ucentral_schema_url, latest_version_id, previous_version_
164173 if changed_items :
165174 changed_items = [list (key ) for key in changed_items ]
166175 changed_items = sorted (changed_items )
167- message = ("Note: The value at these key paths have been modified.\n \n "
168- + tabulate (changed_items , headers = ['Key Paths' , 'Old Value' , 'New Value' ], tablefmt = 'fancy_grid' ))
176+ message = (
177+ "Note: The following key paths have modified values:\n \n "
178+ + convert_changed_items_to_vertical_table (changed_items )
179+ )
169180 logging .info ("\n Changed Items:\n " + message + "\n " )
170181 allure .attach (message , name = "Changed items:" )
171182 pytest .fail (f"Differences found in the schema, check Test Body for Added/Removed/Changed items" )
172183 return
173184
174185
175- def validate_state_message_through_ap (test_object , target_object , config_data ):
186+ def validate_state_message_through_ap (test_object , target_object , config_data , ssid = None ):
176187 def get_type_of_message (message ):
177188 type_of_message = "unknown"
178189 if isinstance (message , dict ):
@@ -316,8 +327,9 @@ def verify_type_of_value(message, schema, path):
316327 radio_5g = dict_all_radios_5g [radio ][0 ]
317328 break
318329
330+ logging .info (f"ssid:{ ssid } " )
319331 test_object .pre_cleanup ()
320- fiveg_sta_got_ip = test_object .client_connect_using_radio (ssid = "captive-credential-4" ,
332+ fiveg_sta_got_ip = test_object .client_connect_using_radio (ssid = ssid ,
321333 passkey = "OpenWifi" ,
322334 security = "wpa2" , radio = radio_5g ,
323335 station_name = ["station-5G" ],
@@ -448,7 +460,7 @@ def test_schema_through_github(self, commit_id):
448460 Objective is to identify any modifications, additions, or removals in the file: ucentral.schema.json.
449461
450462 Unique Marker:
451- schema_validation and through_github and schema_json
463+ schema_validation_tests and through_github and schema_json
452464 """
453465 validate_schema_through_github (commit_id , "/ucentral.schema.json" )
454466
@@ -466,7 +478,7 @@ def test_schema_full_through_github(self, commit_id):
466478 Objective is to identify any modifications, additions, or removals in the file: ucentral.schema.full.json.
467479
468480 Unique Marker:
469- schema_validation and through_github and schema_full_json
481+ schema_validation_tests and through_github and schema_full_json
470482 """
471483 validate_schema_through_github (commit_id , "/ucentral.schema.full.json" )
472484
@@ -483,7 +495,7 @@ def test_schema_pretty_through_github(self, commit_id):
483495 Objective is to identify any modifications, additions, or removals in the file: ucentral.schema.pretty.json.
484496
485497 Unique Marker:
486- schema_validation and through_github and schema_pretty_json
498+ schema_validation_tests and through_github and schema_pretty_json
487499 """
488500 validate_schema_through_github (commit_id , "/ucentral.schema.pretty.json" )
489501
@@ -500,7 +512,7 @@ def test_state_pretty_through_github(self, commit_id):
500512 Objective is to identify any modifications, additions, or removals in the file: ucentral.state.pretty.json.
501513
502514 Unique Marker:
503- schema_validation and through_github and state_pretty_json
515+ schema_validation_tests and through_github and state_pretty_json
504516 """
505517 validate_schema_through_github (commit_id , "/ucentral.state.pretty.json" )
506518
@@ -524,9 +536,10 @@ def test_state_message_schema_master_config_1(self, get_test_library, get_target
524536 Objective is to detect discrepancies in data types (e.g., string to integer) and object structures.
525537
526538 Unique Marker:
527- schema_validation and through_ap_terminal and master_config_1
539+ schema_validation_tests and through_ap_terminal and master_config_1
528540 """
529- validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_1 )
541+ ssid = "captive-credential-4"
542+ validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_1 , ssid = ssid )
530543
531544 @pytest .mark .master_config_2
532545 @allure .title ("Pushing master config-2" )
@@ -541,9 +554,10 @@ def test_state_message_schema_master_config_2(self, get_test_library, get_target
541554 Objective is to detect discrepancies in data types (e.g., string to integer) and object structures.
542555
543556 Unique Marker:
544- schema_validation and through_ap_terminal and master_config_2
557+ schema_validation_tests and through_ap_terminal and master_config_2
545558 """
546- validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_2 )
559+ ssid = "captive-uam-8"
560+ validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_2 , ssid = ssid )
547561
548562 @pytest .mark .master_config_3
549563 @allure .title ("Pushing master config-3" )
@@ -558,6 +572,7 @@ def test_state_message_schema_master_config_3(self, get_test_library, get_target
558572 Objective is to detect discrepancies in data types (e.g., string to integer) and object structures.
559573
560574 Unique Marker:
561- schema_validation and through_ap_terminal and master_config_3
575+ schema_validation_tests and through_ap_terminal and master_config_3
562576 """
563- validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_3 )
577+ ssid = "Uchannel-ds-4"
578+ validate_state_message_through_ap (get_test_library , get_target_object , config_data = config_data_3 , ssid = ssid )
0 commit comments