Best Python code snippet using localstack_python
index.py
Source:index.py  
1print("\n" * 5)                  2import datetime                    3import os                          4list_foods = []                    5list_drinks = []                   6list_services = []                 7list_item_price = [0] * 100        8                                  9var_discount_1 = 200                      10var_discount_2 = 1000                     11var_discount_3 = 5000                     12var_discount_1_rate = 0.05                13var_discount_2_rate = 0.10                14var_discount_3_rate = 0.15                15navigator_symbol = "/" 16if os.name == "nt":17    navigator_symbol = "\\" 18def def_default():19    global list_drinks, list_foods, list_services, list_item_order, list_item_price     20    list_item_order = [0] * 100                    21def_default()                                      22                                                   23def def_main():24    while True:25        print("*" * 28 + "FOOD ORDERING SYSTEM" + "*" * 24 + "\n") 26        print("*" * 31 + "MAIN MENU" + "*" * 32 + "\n"     27              "\t(O) ORDER\n"                              28              "\t(R) REPORT\n"29              "\t(P) PAYMENT\n"30              "\t(E) EXIT\n" +31              "_" * 72)32        input_1 = str(input("Please Select Your Operation: ")).upper()    33        if (len(input_1) == 1):                                           34            if (input_1 == 'O'):                                          35                print("\n" * 10)                                        36                def_order_menu()                                          37                break                                                     38            elif (input_1 == 'R'):                                        39                print("\n" * 10)                                        40                def_report()                                              41                break                                                     42            elif (input_1 == 'P'):                                        43                print("\n" * 10)                                         44                def_payment()                                             45                break                                                     46            elif (input_1 == 'E'):                                        47                print("*" * 32 + "THANK YOU" + "*" * 31 + "\n")           48                break                                                     49            else:                                                                                 50                print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")     51        else:                                                                                     52            print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")        53def def_order_menu():                                                                               54    while True:                                             55        print("*" * 31 + "ORDER PAGE" + "*" * 31 + "\n"    56              "\t(F) FOODS AND DRINKS\n"57              "\t(O) OTHER SERVICES\n"58              "\t(M) MAIN MENU\n"59              "\t(E) EXIT\n" +60              "_" * 72)61        input_1 = str(input("Please Select Your Operation: ")).upper() 62        if len(input_1) == 1:63            if (input_1 == 'F'):  64                print("\n" * 10)65                def_food_drink_order()66                break67            elif (input_1 == 'O'):68                print("\n" * 10)69                def_other_services() 70                break71            elif (input_1 == 'M'):72                print("\n" * 10)73                def_main() 74                break75            elif (input_1 == 'E'):76                print("*" * 32 + "THANK YOU" + "*" * 31 + "\n")77                break78            else:79                print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!") 80        else:81            print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")82def def_full_file_reader():                                                                        83    file_foods = open('files'+navigator_symbol+'list_foods.fsd', 'r') 84    for i in file_foods: 85        list_foods.append(str(i.strip())) 86    file_foods.close()87    file_drinks = open('files'+navigator_symbol+'list_drinks.fsd', 'r') 88    for i in file_drinks:89        list_drinks.append(str(i.strip()))90    file_drinks.close()91    file_services = open('files'+navigator_symbol+'list_services.fsd', 'r') 92    for i in file_services:93        list_services.append(str(i.strip()))94    file_services.close()95    i = 096    while i <= (len(list_foods) - 1): 97        if '$' in list_foods[i]:98            list_foods[i] = str(list_foods[i][:list_foods[i].index('$') - 1]) + ' ' * (20 - (list_foods[i].index('$') - 1)) + str(list_foods[i][list_foods[i].index('$'):])99        i += 1100    i = 0101    while i <= (len(list_drinks) - 1):102        if '$' in list_drinks[i]:103            list_drinks[i] = str(list_drinks[i][:list_drinks[i].index('$') - 1]) + ' ' * (20 - (list_drinks[i].index('$') - 1)) + str(list_drinks[i][list_drinks[i].index('$'):])104        i += 1105    i = 0106    while i <= (len(list_services) - 1):107        if '$' in list_services[i]:108            list_services[i] = str(list_services[i][:list_services[i].index('$') - 1]) + ' ' * (20 - (list_services[i].index('$') - 1)) + str(list_services[i][list_services[i].index('$'):])109        i += 1110def_full_file_reader()111def def_file_sorter(): 112    global list_foods, list_drinks, list_services113    list_foods = sorted(list_foods)114    list_drinks = sorted(list_drinks)115    list_services = sorted(list_services)116    i = 0117    while i < len(list_foods):118        list_item_price[i] = float(list_foods[i][int(list_foods[i].index("$") + 2):]) 119        i += 1120    i = 0121    while i < len(list_drinks):122        list_item_price[40 + i] = float(list_drinks[i][int(list_drinks[i].index("$") + 2):]) 123        i += 1124    i = 0125    while i < len(list_services):126        list_item_price[80 + i] = float(list_services[i][int(list_services[i].index("$") + 2):]) 127        i += 1128def_file_sorter()129def def_food_drink_order():130    while True:131            print("*" * 26 + "ORDER FOODS & DRINKS" + "*" * 26)132            print(" |NO| |FOOD NAME|         |PRICE|   |  |NO| |DRINK NAME|        |PRICE|")133            i = 0134            while i < len(list_foods) or i < len(list_drinks):135                var_space = 1136                if i <= 8:                      137                    var_space = 2138                if i < len(list_foods):139                    food = " (" + str(i + 1) + ")" + " " * var_space + str(list_foods[i]) + "  | " 140                else:141                    food = " " * 36 + "| " 142                if i < len(list_drinks):143                    drink = "(" + str(41 + i) + ")" + " " + str(list_drinks[i])144                else:145                    drink = ""146                print(food, drink)147                i += 1148            print("\n (M) MAIN MENU                   (P) PAYMENT                   (E) EXIT\n" + "_" * 72)149            input_1 = input("Please Select Your Operation: ").upper() 150            if (input_1 == 'M'):151                print("\n" * 10)152                def_main() 153                break154            if (input_1 == 'E'):155                print("*" * 32 + "THANK YOU" + "*" * 31 + "\n") 156                break157            if (input_1 == 'P'):158                print("\n" * 10)159                def_payment() 160                break161            try:        162                int(input_1)163                if ((int(input_1) <= len(list_foods) and int(input_1) > 0) or (int(input_1) <= len(list_drinks) + 40 and int(input_1) > 40)):164                     try:165                        print("\n" + "_" * 72 + "\n" + str(list_foods[int(input_1) - 1])) 166                     except:167                        pass168                     try:169                         print("\n" + "_" * 72 + "\n" + str(list_drinks[int(input_1) - 41])) 170                     except:171                        pass172                     input_2 = input("How Many You Want to Order?: ").upper() 173                     if int(input_2) > 0:174                        list_item_order[int(input_1) - 1] += int(input_2) 175                        print("\n" * 10)176                        print("Successfully Ordered!")177                        def_food_drink_order() 178                        break179                     else:180                        print("\n" * 10 + "ERROR: Invalid Input (" + str(input_2) + "). Try again!")181            except:182                print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")183def def_other_services():184    while True:185        print("*" * 29 + "OTHER SERVICES" + "*" * 29)186        print(" |NO| |SERVICE NAME|      |PRICE|")  187        i = 0188        while i < len(list_services):189            print(" (" + str(81+ i) + ")" + " " + str(list_services[i])) 190            i += 1191        print("\n (M) MAIN MENU                   (P) PAYMENT                   (E) EXIT\n" + "_" * 72)192        input_1 = input("Please Select Your Operation: ").upper()193        if (input_1 == 'M'):194            print("\n" * 10)195            def_main() 196            break197        if (input_1 == 'E'):198            print("*" * 32 + "THANK YOU" + "*" * 31 + "\n")199            break200        if (input_1 == 'P'):201            print("\n" * 10)202            def_payment() 203            break204        try:205            int(input_1)206            if (int(input_1) > 80) and (int(input_1) < 100):207                print("\n" * 10)208                print("Successfully Ordered: " + str(list_services[int(input_1) - 81])) 209                list_item_order[int(input_1) - 1] = 1210                def_other_services()211                break212            else:213                print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")214        except:215            print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")216def def_report():217    while True:218        print("*" * 33 + "REPORT" + "*" * 33 + "\n")219        file_report = open('files'+navigator_symbol+'report.fsd', 'r').read() 220        print(file_report)221        print("\n(M) MAIN MENU          (E) EXIT\n" + "_" * 72)222        input_1 = str(input("Please Select Your Operation: ")).upper()223        if (input_1 == 'M'):224            print("\n" * 10)225            def_main() 226            break227        elif (input_1 == 'E'):228            print("*" * 32 + "THANK YOU" + "*" * 31 + "\n") 229            break230        else:231            print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")232def def_payment():233    while True:234        print("*" * 32 + "PAYMENT" + "*" * 33 + "\n") 235        total_price = 0 236        report_new = "\n\n\n" + " " * 17 + "*" * 35 + "\n" + " " * 17 + "DATE: " + str(datetime.datetime.now())[:19] + "\n" + " " * 17 + "-" * 35 237        i = 0238        while i < len(list_item_order): 239            if(list_item_order[i] != 0):240                if (i >= 0) and (i < 40):241                    report_new += "\n" + " " * 17 + str(list_foods[i]) + "  x  " + str(list_item_order[i]) 242                    print(" " * 17 + str(list_foods[i]) + "  x  " + str(list_item_order[i])) 243                    total_price += list_item_price[i] * list_item_order[i] 244                if (i >= 40) and (i < 80):245                    report_new += "\n" + " " * 17 + str(list_drinks[i - 40]) + "  x  " + str(list_item_order[i])246                    print(" " * 17 + str(list_drinks[i - 40]) + "   x  " + str(list_item_order[i]))247                    total_price += list_item_price[i] * list_item_order[i] 248                if (i >= 80) and (i < 100):249                    report_new += "\n" + " " * 17 + str(list_services[i - 80])250                    print(" " * 17 + str(list_services[i - 80]))251                    total_price += list_item_price[i] * list_item_order[i] 252                i += 1253            else:254                i += 1255        256        if total_price > var_discount_3: 257            total_price -= total_price * var_discount_3_rate 258            report_new += "\n" + " " * 17 + "-" * 35 + "\n" \259                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_3_rate * 100) + "\n" \260                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_3_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n" \261                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)) + "\n" + " " * 17 + "*" * 35 262            print(" " * 17 + "-" * 35 + "\n"263                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_3_rate * 100) + "\n"264                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_3_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n"265                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)))266        elif total_price > var_discount_2: 267            total_price -= total_price * var_discount_2_rate 268            report_new += "\n" + " " * 17 + "-" * 35 + "\n" \269                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_2_rate * 100) + "\n" \270                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_2_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n" \271                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)) + "\n" + " " * 17 + "*" * 35 272            print(" " * 17 + "-" * 35 + "\n"273                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_2_rate * 100) + "\n"274                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_2_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n"275                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)))276        elif total_price > var_discount_1: 277            total_price -= total_price * var_discount_1_rate 278            report_new += "\n" + " " * 17 + "-" * 35 + "\n" \279                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_1_rate * 100) + "\n" \280                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_1_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n" \281                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)) + "\n" + " " * 17 + "*" * 35 282            print(" " * 17 + "-" * 35 + "\n"283                "" + " " * 17 + "DISCOUNT RATES:      % " + str(var_discount_1_rate * 100) + "\n"284                "" + " " * 17 + "DISCOUNT AMOUNTS:   $ " + str(round(total_price * var_discount_1_rate, 2)) + "\n" + " " * 17 + "_" * 35 + "\n"285                "" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)))286        else:287            report_new += "\n" + " " * 17 + "-" * 35 + "\n" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)) + "\n" + " " * 17 + "*" * 35288            print(" " * 17 + "_" * 35 + "\n" + " " * 17 + "TOTAL PRICES:       $ " + str(round(total_price, 2)))289        print("\n (P) PAY           (M) MAIN MENU           (R) REPORT          (E) EXIT\n" + "_" * 72)290        input_1 = str(input("Please Select Your Operation: ")).upper()291        if (input_1 == 'P'):292            print("\n" * 10)293            print("Successfully Paid!")294            file_report = open('files'+navigator_symbol+'report.fsd', 'a') 295            file_report.write(report_new)296            file_report.close()297            def_default() 298        elif (input_1 == 'M'):299            print("\n" * 10)300            def_main() 301            break302        elif (input_1 == 'R'):303            print("\n" * 10)304            def_report() 305            break306        elif ('E' in input_1) or ('e' in input_1):307            print("*" * 32 + "THANK YOU" + "*" * 31 + "\n")308            break309        else:310            print("\n" * 10 + "ERROR: Invalid Input (" + str(input_1) + "). Try again!")...finder.py
Source:finder.py  
1234new_index =0567# =============================================================================8# #9# =============================================================================1011def add_extra_scenario(datasheet,s_name,config_scenario):1213#    s_name = service_name.get_service_in_use()14    service = datasheet.get("service") 15    find_service(service,s_name,config_scenario)16   17def find_service(service,name,config_scenario):18    data=""19    is_find = True20    name_ser= service.get("name")21    if name_ser==name:22        data=service23        add_scenario_config(service,config_scenario)24       25        26        is_find=False27    if is_find:28       for key in  service.keys():29            if key != "name": 30                config=service.get(key)31                find_service_config(config,name,config_scenario)32 33    return data3435def find_service_config(config,name,config_scenario):36    37     for key in  config.keys():38            if key == "service": 39                service=config.get("service")40                find_service(service,name,config_scenario)41            else: 42                list_services = config.get(key).get("service")43                if list_services:4445                    for service in list_services:46                       find_service(service,name,config_scenario)4748def add_scenario_config(service,config_scenario):49    50       51    service.update(config_scenario)52    return service53   545556# =============================================================================57# 58# =============================================================================5960def find__alt_vp(datasheet):61    62    service = datasheet.get("service") 63    list_services = find_vp(service)64    return list_services65   66def find_vp(service):67    list_service=[]68    for key in  service.keys():69            if key != "name" and key != "requires" and key != "excludes": 70                config=service.get(key)71                list_service=find_vp_config(config)72 73    return list_service7475def find_vp_config(config):76    global new_index77    list_services=[]78    79    for key in  config.keys():80        if key == "AlternativeVP": 81            if new_index==1:82                list_services=get_name_services(config.get(key).get("service"))83              84            else:85                new_index=new_index-186                list_aux_services = config.get(key).get("service")87                for service in list_aux_services:88                      if  list_services==[]:89                          list_services=find_vp(service)90                          91        else: 92           list_aux_services = config.get(key).get("service")93           for service in list_aux_services:94               if  list_services==[]:95                   list_services=find_vp(service)96    return list_services9798def get_name_services(list_services):99    list_ser=[]100    for services in list_services:101        list_ser.append(services.get("name"))102    return list_ser103104# =============================================================================105# 106# =============================================================================107108109def find_parent_list(datasheet,name):110    111    service = datasheet.get("service") 112    list_services = find_parent(service,name)113    if list_services !=[]:114        list_services.remove(name)115    return list_services116   117def find_parent(service,name):118  119    list_service=[]120    actual_name= config=service.get("name")121    is_find= True122    if actual_name== name:123        list_service=[name]124        is_find =False125    if is_find:126        for key in service.keys():127                if key != "name" and key != "requires" and key != "excludes": 128                    config=service.get(key)129                    list_service=find_parent_vp_config(config,name)130                    if list_service!=[]:131                       list_service.append(actual_name)132 133    return list_service134135def find_parent_vp_config(config,name):136    global new_index137    list_services=[]138    is_find=True139    for key in  config.keys():140        if key == "AlternativeVP": 141            list_aux_services = config.get(key).get("service")142            for service in list_aux_services:143                if is_find:144                    if  list_services==[]:145                        list_services=find_parent(service,name)146                        if list_services != []:147                            is_find=False148                          149        else: 150           list_aux_services = config.get(key).get("service")151           for service in list_aux_services:152               if is_find:153                   if  list_services==[]:154                       list_services=find_parent(service,name)155                       if list_services != []:156                                is_find=False157    return list_services158159# =============================================================================160# 161# =============================================================================162163164165def find_mandatory_list(datasheet):166    167    service = datasheet.get("service") 168    list_services = find_mand(service)169    return list_services170   171def find_mand(service):172   173    list_service=[]174    actual_name= config=service.get("name")175    for key in service.keys():176        if key != "name" and key != "requires" and key != "excludes": 177            config=service.get(key)178            list_service=list_service + find_mand_config(config)179        if key == "requires": 180            config=service.get(key).get("service")181            list_service=list_service + find_mand(config)182               183    list_service.append(actual_name)184 185    return list_service186187def find_mand_config(config):188    global new_index189    list_services=[]190   191    for key in  config.keys():192        if key == "MandatoryVP": 193            list_aux_services = config.get(key).get("service")194            for service in list_aux_services:195                list_services=list_services + find_mand(service)196                       197    return list_services198199200# =============================================================================201# 202    203# =============================================================================204  205206207def diff(list1, list2): 208    c = set(list1).union(set(list2)) 209   210    d = set(list1).intersection(set(list2))211212    return list(c - d)213                        214215# =============================================================================216# 217# =============================================================================218219220221222def change_mand_vp(datasheet,num_vp):223    global new_index224    new_index = num_vp225    service = datasheet.get("service") 226    list_services = find_mand_vp(service)227    return list_services228   229def find_mand_vp(service):230    global new_index231  232    band = False233    for key in  service.keys():234            if key != "name" and key != "requires" and key != "excludes": 235                config=service.get(key)236                band=find_mand_scope_config(config)237                if band and new_index!=-1:238                    if  key!="SpecificVariationPoint":239                240                       vp_aux={"SpecificVariationPoint":config}241                       service.pop("GlobalVariationPoint")242                       service.update(vp_aux)243                       band =False244                       new_index = -1245                       246                       247 248    return band249250def find_mand_scope_config(config):251    global new_index252    band =False253    for key in  config.keys():254        if key == "MandatoryVP": 255            if new_index==1:256                band=True257              258            else:259                new_index=new_index-1260                list_aux_services = config.get(key).get("service")261                for service in list_aux_services:262                      if  band==False:263                          band=find_mand_vp(service)264                          265        else: 266           list_aux_services = config.get(key).get("service")267           for service in list_aux_services:268               if  band==False:269                   band=find_mand_vp(service)270                   271                   272    return band273274# =============================================================================275# 276# =============================================================================277278279    280datashet = {"id": "Model_Name", 281  "service": {282         "name": "A", 283         "GlobalVariationPoint": {284                 "MandatoryVP": {285                         "service": [{286                                 "name": "B", 287                                 "GlobalVariationPoint": {288                                         "OptionalVP": {289                                                 "service": [{290                                                         "name": "B1", "requires": {"Service": {"name": "B1"}}}]}}, 291                                 "requires": {"service": {"name": "E"}}, 292                                 "excludes": {"Service": {"name": "C"}}}, {"name": "C", "GlobalVariationPoint": {"VariantVP": {"service": [{"name": "C1", "requires": {"Service": {"name": "C1"}}}, {"name": "C2"}]}}, "excludes": {"service": {"name": "A"}}, "requires": {"service": {"name": "C1", "requires": {"Service": {"name": "C1"}}}}}]}}, "requires": {"service": {"name": "A"}}, "excludes": {"service": {"name": "B", "excludes": {"Service": {"name": "C"}}}}}} 293294295#change_opt_vp(datashet,2)296#
...test_services.py
Source:test_services.py  
...27        super(ServicesAdminV3TestJSON, cls).setUpClass()28        cls.client = cls.services_admin_client29        cls.non_admin_client = cls.services_client30    @attr(type='gate')31    def test_list_services(self):32        resp, services = self.client.list_services()33        self.assertEqual(200, resp.status)34        self.assertNotEqual(0, len(services))35    @attr(type=['negative', 'gate'])36    def test_list_services_with_non_admin_user(self):37        self.assertRaises(exceptions.Unauthorized,38                          self.non_admin_client.list_services)39    @attr(type='gate')40    def test_get_service_by_service_binary_name(self):41        binary_name = 'nova-compute'42        params = {'binary': binary_name}43        resp, services = self.client.list_services(params)44        self.assertEqual(200, resp.status)45        self.assertNotEqual(0, len(services))46        for service in services:47            self.assertEqual(binary_name, service['binary'])48    @attr(type='gate')49    def test_get_service_by_host_name(self):50        resp, services = self.client.list_services()51        host_name = services[0]['host']52        services_on_host = [service for service in services if53                            service['host'] == host_name]54        params = {'host': host_name}55        resp, services = self.client.list_services(params)56        # we could have a periodic job checkin between the 2 service57        # lookups, so only compare binary lists.58        s1 = map(lambda x: x['binary'], services)59        s2 = map(lambda x: x['binary'], services_on_host)60        # sort the lists before comparing, to take out dependency61        # on order.62        self.assertEqual(sorted(s1), sorted(s2))63    @attr(type=['negative', 'gate'])64    def test_get_service_by_invalid_params(self):65        # return all services if send the request with invalid parameter66        resp, services = self.client.list_services()67        params = {'xxx': 'nova-compute'}68        resp, services_xxx = self.client.list_services(params)69        self.assertEqual(200, resp.status)70        self.assertEqual(len(services), len(services_xxx))71    @attr(type='gate')72    def test_get_service_by_service_and_host_name(self):73        resp, services = self.client.list_services()74        host_name = services[0]['host']75        binary_name = services[0]['binary']76        params = {'host': host_name, 'binary': binary_name}77        resp, services = self.client.list_services(params)78        self.assertEqual(200, resp.status)79        self.assertEqual(1, len(services))80        self.assertEqual(host_name, services[0]['host'])81        self.assertEqual(binary_name, services[0]['binary'])82    @attr(type=['negative', 'gate'])83    def test_get_service_by_invalid_service_and_valid_host(self):84        resp, services = self.client.list_services()85        host_name = services[0]['host']86        params = {'host': host_name, 'binary': 'xxx'}87        resp, services = self.client.list_services(params)88        self.assertEqual(200, resp.status)89        self.assertEqual(0, len(services))90    @attr(type=['negative', 'gate'])91    def test_get_service_with_valid_service_and_invalid_host(self):92        resp, services = self.client.list_services()93        binary_name = services[0]['binary']94        params = {'host': 'xxx', 'binary': binary_name}95        resp, services = self.client.list_services(params)96        self.assertEqual(200, resp.status)97        self.assertEqual(0, len(services))98    @attr(type='gate')99    def test_service_enable_disable(self):100        resp, services = self.client.list_services()101        host_name = services[0]['host']102        binary_name = services[0]['binary']103        resp, service = self.client.disable_service(host_name, binary_name)104        self.assertEqual(200, resp.status)105        params = {'host': host_name, 'binary': binary_name}106        resp, services = self.client.list_services(params)107        self.assertEqual('disabled', services[0]['status'])108        resp, service = self.client.enable_service(host_name, binary_name)109        self.assertEqual(200, resp.status)110        resp, services = self.client.list_services(params)111        self.assertEqual('enabled', services[0]['status'])112class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
