66import os
77import unittest
88
9+ from datetime import datetime
910from azure_devtools .scenario_tests import AllowLargeResponse
1011from .utilities .helper import DevopsScenarioTest , disable_telemetry , set_authentication , get_test_org_from_env_variable
1112
@@ -23,26 +24,33 @@ def test_admin_banner_addUpdateShowListRemove(self):
2324 admin_banner_updated_message = 'Sample updated banner message'
2425 admin_banner_updated_type = 'error'
2526 admin_banner_id = self .create_random_name (prefix = 'banner-id-' , length = 15 )
27+ admin_banner_expiration_date = datetime .today ().strftime ('%Y-%m-%d' )
2628
2729 try :
2830 #add a banner to the project
2931 add_admin_banner_command = ('az devops admin banner add --id ' + admin_banner_id + ' --message "' + admin_banner_message + '" --type ' + admin_banner_type +
32+ ' --expiration ' + admin_banner_expiration_date +
3033 ' --output json --detect false --debug' )
3134 add_admin_banner_output = self .cmd (add_admin_banner_command ).get_output_in_json ()
3235 assert len (add_admin_banner_output ) > 0
3336 assert add_admin_banner_output [admin_banner_id ]["level" ] == admin_banner_type
3437 assert add_admin_banner_output [admin_banner_id ]["message" ] == admin_banner_message
38+ from azext_devops .dev .common .arguments import convert_date_string_to_iso8601
39+ iso_date = convert_date_string_to_iso8601 (admin_banner_expiration_date )
40+ assert add_admin_banner_output [admin_banner_id ]["expirationDate" ] == iso_date
3541
3642 #Test was failing without adding a sleep here. Though the create was successful when queried after few seconds.
3743 self .sleep_in_live_run (5 )
3844
3945 #update banner
4046 update_admin_banner_command = ('az devops admin banner update --id ' + admin_banner_id + ' --message "' + admin_banner_updated_message +
41- '" --type ' + admin_banner_updated_type + ' --output json --detect false' )
47+ '" --expiration ' + '""' +
48+ ' --type ' + admin_banner_updated_type + ' --output json --detect false' )
4249 update_admin_banner_output = self .cmd (update_admin_banner_command ).get_output_in_json ()
4350 assert len (update_admin_banner_output [admin_banner_id ]) > 0
4451 assert update_admin_banner_output [admin_banner_id ]["level" ] == admin_banner_updated_type
4552 assert update_admin_banner_output [admin_banner_id ]["message" ] == admin_banner_updated_message
53+ assert update_admin_banner_output [admin_banner_id ]["expirationDate" ] == ''
4654
4755 #Test was failing without adding a sleep here. Though the update was successful when queried after few seconds.
4856 self .sleep_in_live_run (5 )
0 commit comments