Best Python code snippet using pandera_python
calculatetotaltests.py
Source:calculatetotaltests.py  
...9        def setUp(self):10            self.order_id = str(uuid.uuid4())11        def test_calculate_total_for_order_with_no_specials_and_4_items(self):12            datastore = DataStore()13            item  = self.create_item('soup', 2.00, 'unit', None, datastore)14            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)15            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)16            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)17            order = self.create_order(datastore)18            order.add_item(item, 3)19            order.add_item(item2, 1)20            order.add_item(item3, 4.32)21            order.add_item(item4, 9.34)22            total = order.calculate_total()23            self.assertEqual(total, 111.33)24        def test_calculate_total_for_order_with_no_specials_and_4_items_2(self):25            datastore = DataStore()26            item  = self.create_item('soup', 2.00, 'unit', None, datastore)27            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)28            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)29            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)30            order = self.create_order(datastore)31            order.add_item(item, 1)32            order.add_item(item2, 1)33            order.add_item(item3, 5.32)34            order.add_item(item4, 99.34)35            total = order.calculate_total()36            self.assertEqual(total, 1008.80)37        def test_calculate_total_for_order_with_no_specials_and_no_items(self):38            datastore = DataStore()39            item  = self.create_item('soup', 2.00, 'unit', None, datastore)40            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)41            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)42            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)43            order = self.create_order(datastore)44            total = order.calculate_total()45            self.assertEqual(total, 0.00)46        def test_calculate_total_for_order_with_one_markdown_special_and_4_items(self):47            datastore = DataStore()48            special = {49                'type': 'markdown',50                'price': 0.50,51                'limit': 652            }53            item  = self.create_item('soup', 2.00, 'unit', special, datastore)54            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)55            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)56            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)57            order = self.create_order(datastore)58            order.add_item(item, 3)59            order.add_item(item2, 1)60            order.add_item(item3, 4.32)61            order.add_item(item4, 9.34)62            total = order.calculate_total()63            self.assertEqual(total, 109.83)64        def test_calculate_total_for_order_with_two_markdown_specials_and_4_items(self):65            datastore = DataStore()66            special1 = {'type': 'markdown','price': 0.50,'limit': 6}67            special2 = {'type': 'markdown','price': 0.89}68            item  = self.create_item('soup', 2.00, 'unit', special1, datastore)69            item2 = self.create_item('peas', 1.78, 'unit', special2, datastore)70            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)71            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)72            order = self.create_order(datastore)73            order.add_item(item, 3)74            order.add_item(item2, 1)75            order.add_item(item3, 4.32)76            order.add_item(item4, 9.34)77            total = order.calculate_total()78            self.assertEqual(total, 108.94)79        def test_calculate_total_for_order_with_one_AforB_special_and_4_items(self):80            datastore = DataStore()81            special1 = {'type': 'AforB', 'buy': 2, 'for': 2.00}82            item  = self.create_item('soup', 2.00, 'unit', special1, datastore)83            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)84            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)85            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)86            order = self.create_order(datastore)87            order.add_item(item, 4)88            order.add_item(item2, 1)89            order.add_item(item3, 4.32)90            order.add_item(item4, 9.34)91            total = order.calculate_total()92            self.assertEqual(total, 109.33)93        def test_calculate_total_for_order_with_one_AforB_special_and_markdown_and_4_items(self):94            datastore = DataStore()95            special1 = {'type': 'AforB', 'buy': 2, 'for': 2.00}96            special2 = {'type': 'markdown','price': 0.89}97            item  = self.create_item('soup', 2.00, 'unit', special1, datastore)98            item2 = self.create_item('peas', 1.78, 'unit', special2, datastore)99            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)100            item4 = self.create_item('beef', 9.99, 'weight', None, datastore)101            order = self.create_order(datastore)102            order.add_item(item, 4)103            order.add_item(item2, 1)104            order.add_item(item3, 4.32)105            order.add_item(item4, 9.34)106            total = order.calculate_total()107            self.assertEqual(total, 108.44)108        def test_calculate_total_for_order_with_one_getEOLforAoff_special_and_markdown_and_4_items(self):109            datastore = DataStore()110            special1 = {'type': 'getEOLforAoff', 'off': 75}111            special2 = {'type': 'markdown', 'price': 0.89}112            item  = self.create_item('soup', 2.00, 'unit', None, datastore)113            item2 = self.create_item('peas', 1.78, 'unit', special2, datastore)114            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)115            item4 = self.create_item('beef', 9.99, 'weight', special1, datastore)116            order = self.create_order(datastore)117            order.add_item(item, 4)118            order.add_item(item2, 1)119            order.add_item(item3, 4.32)120            order.add_item(item4, 9.34)121            total = order.calculate_total()122            self.assertEqual(total, 104.76)123        def test_calculate_total_for_order_with_one_getEOLforAoff_special_and_markdown_and_4_items_2(self):124            datastore = DataStore()125            special1 = {'type': 'getEOLforAoff', 'off': 25}126            special2 = {'type': 'markdown', 'price': 1.00}127            item  = self.create_item('soup', 2.00, 'unit', special2, datastore)128            item2 = self.create_item('peas', 1.78, 'unit', None, datastore)129            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)130            item4 = self.create_item('beef', 9.99, 'weight', special1, datastore)131            order = self.create_order(datastore)132            order.add_item(item, 4)133            order.add_item(item2, 1)134            order.add_item(item3, 4.32)135            order.add_item(item4, 9.34)136            total = order.calculate_total()137            self.assertEqual(total, 106.77)138        def test_calculate_total_for_order_with_one_getEOLforAoff_and_markdown_and_AforB_5_items(self):139            datastore = DataStore()140            special1 = {'type': 'getEOLforAoff', 'off': 25}141            special2 = {'type': 'markdown', 'price': 4.00}142            special3 = {'type': 'AforB', 'buy': 3, 'for': 5.00}143            item  = self.create_item('soup'   , 2.00, 'unit', special3, datastore)144            item2 = self.create_item('peas'   , 1.78, 'unit', None, datastore)145            item3 = self.create_item('chicken', 2.37, 'weight', None, datastore)146            item4 = self.create_item('beef'   , 9.99, 'weight', special1, datastore)147            item5 = self.create_item('cheese' , 8.00, 'unit', special2, datastore)148            order = self.create_order(datastore)149            order.add_item(item , 4)150            order.add_item(item2, 1)151            order.add_item(item3, 1.32)152            order.add_item(item4, 9.34)153            order.add_item(item5, 2)154            total = order.calculate_total()155            self.assertEqual(total, 112.44)156        def test_calculate_total_for_order_with_6_specials_and_10_items(self):157            datastore = DataStore()158            special1 = {'type': 'getEOLforAoff', 'off': 25}159            special2 = {'type': 'markdown', 'price': 4.00}160            special3 = {'type': 'AforB', 'buy': 3, 'for': 5.00}161            special4 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 50}162            special5 = {'type': 'markdown', 'price': 0.50}163            special6 = {'type': 'getEOLforAoff', 'off': 35}164            item  = self.create_item('soup'    , 2.00, 'unit'  , special3, datastore)165            item2 = self.create_item('peas'    , 1.78, 'unit'  , None, datastore)166            item3 = self.create_item('chicken' , 2.37, 'weight', None, datastore)167            item4 = self.create_item('beef'    , 9.99, 'weight', special1, datastore)168            item5 = self.create_item('cheese'  , 8.00, 'unit'  , special2, datastore)169            item6 = self.create_item('corn'    , 3.27, 'weight', special6, datastore)170            item7 = self.create_item('chips'   , 4.99, 'unit'  , None, datastore)171            item8 = self.create_item('crackers', 2.68, 'unit'  , special4, datastore)172            item9 = self.create_item('butter'  , 1.99, 'unit'  , special5, datastore)173            item10= self.create_item('eggs'    , 0.89, 'unit'  , None, datastore)174            order = self.create_order(datastore)175            order.add_item(item ,  4)176            order.add_item(item2,  1)177            order.add_item(item3,  1.32)178            order.add_item(item4,  9.34)179            order.add_item(item5,  2)180            order.add_item(item6,  3.56)181            order.add_item(item7,  3)182            order.add_item(item8,  4)183            order.add_item(item9,  1)184            order.add_item(item10, 1)185            total = order.calculate_total()186            self.assertEqual(total, 147.25)187        def test_calculate_total_for_order_with_6_specials_and_10_items_with_limits(self):188            datastore = DataStore()189            special1 = {'type': 'getEOLforAoff', 'off': 25}190            special2 = {'type': 'markdown', 'price': 4.00}191            special3 = {'type': 'AforB', 'buy': 3, 'for': 5.00}192            special4 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 50}193            special5 = {'type': 'markdown', 'price': 0.72, 'limit': 5}194            special6 = {'type': 'getEOLforAoff', 'off': 35}195            item  = self.create_item('soup'    , 2.00, 'unit'  , special3, datastore)196            item2 = self.create_item('peas'    , 1.78, 'unit'  , None, datastore)197            item3 = self.create_item('chicken' , 2.37, 'weight', None, datastore)198            item4 = self.create_item('beef'    , 9.99, 'weight', special1, datastore)199            item5 = self.create_item('cheese'  , 8.00, 'unit'  , special2, datastore)200            item6 = self.create_item('corn'    , 3.27, 'weight', special6, datastore)201            item7 = self.create_item('chips'   , 4.99, 'unit'  , None, datastore)202            item8 = self.create_item('crackers', 2.68, 'unit'  , special4, datastore)203            item9 = self.create_item('butter'  , 1.99, 'unit'  , None, datastore)204            item10= self.create_item('eggs'    , 2.89, 'unit'  , special5, datastore)205            order = self.create_order(datastore)206            order.add_item(item ,  4)207            order.add_item(item2,  1)208            order.add_item(item3,  1.32)209            order.add_item(item4,  9.34)210            order.add_item(item5,  2)211            order.add_item(item6,  3.56)212            order.add_item(item7,  3)213            order.add_item(item8,  4)214            order.add_item(item9,  1)215            order.add_item(item10, 10)216            total = order.calculate_total()217            self.assertEqual(total, 172.16)218        def test_calculate_total_greedy_for_order_with_9_specials_and_10_items(self):219            datastore = DataStore()220            special1 = {'type': 'getEOLforAoff', 'off': 25}221            special2 = {'type': 'markdown', 'price': 4.00}222            special3 = {'type': 'AforB', 'buy': 3, 'for': 5.00}223            special4 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 50}224            special5 = {'type': 'markdown', 'price': 0.50}225            special6 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 100}226            special7 = {'type': 'markdown', 'price': 0.62}227            special8 = {'type': 'getEOLforAoff', 'off': 35}228            special9 = {'type': 'AforB', 'buy': 2, 'for': 3.00}229            item  = self.create_item('soup'    , 2.00, 'unit'  , special3, datastore)230            item2 = self.create_item('peas'    , 1.78, 'unit'  , special7, datastore)231            item3 = self.create_item('chicken' , 2.37, 'weight', special8, datastore)232            item4 = self.create_item('beef'    , 9.99, 'weight', special1, datastore)233            item5 = self.create_item('cheese'  , 8.00, 'unit'  , special2, datastore)234            item6 = self.create_item('corn'    , 3.27, 'unit'  , special6, datastore)235            item7 = self.create_item('chips'   , 4.99, 'unit'  , special9, datastore)236            item8 = self.create_item('crackers', 2.68, 'unit'  , special4, datastore)237            item9 = self.create_item('butter'  , 1.99, 'unit'  , special5, datastore)238            item10= self.create_item('eggs'    , 0.89, 'unit'  , None, datastore)239            order = self.create_order(datastore)240            order.add_item(item ,  4)241            order.add_item(item2,  1)242            order.add_item(item3,  1.32)243            order.add_item(item4,  9.34)244            order.add_item(item5,  2)245            order.add_item(item6,  4)246            order.add_item(item7,  3)247            order.add_item(item8,  4)248            order.add_item(item9,  1)249            order.add_item(item10, 1)250            total = order.calculate_total()251            self.assertEqual(total, 162.87)252        def test_calculate_total_greedy_for_order_with_9_specials_and_9_items(self):253            datastore = DataStore()254            special1 = {'type': 'getEOLforAoff', 'off': 25}255            special2 = {'type': 'markdown', 'price': 4.00}256            special3 = {'type': 'AforB', 'buy': 3, 'for': 5.00}257            special4 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 50, 'limit': 2}258            special5 = {'type': 'markdown', 'price': 0.22}259            special6 = {'type': 'buyAgetBforCoff', 'buy': 1, 'get': 1, 'off': 100}260            special7 = {'type': 'markdown', 'price': 0.62}261            special8 = {'type': 'getEOLforAoff', 'off': 35}262            special9 = {'type': 'AforB', 'buy': 2, 'for': 3.00}263            item  = self.create_item('soup'    , 2.00, 'unit'  , special3, datastore)264            item2 = self.create_item('peas'    , 1.78, 'unit'  , special7, datastore)265            item3 = self.create_item('chicken' , 2.37, 'weight', special1, datastore)266            item4 = self.create_item('beef'    , 9.99, 'weight', special8, datastore)267            item5 = self.create_item('cheese'  , 8.00, 'unit'  , special2, datastore)268            item6 = self.create_item('corn'    , 3.27, 'unit'  , special6, datastore)269            item7 = self.create_item('chips'   , 4.99, 'unit'  , special9, datastore)270            item8 = self.create_item('crackers', 2.68, 'unit'  , special4, datastore)271            item10= self.create_item('eggs'    , 0.89, 'unit'  , special5, datastore)272            order = self.create_order(datastore)273            order.add_item(item ,  4)274            order.add_item(item2,  1)275            order.add_item(item3,  6.32)276            order.add_item(item4,  2.34)277            order.add_item(item5,  2)278            order.add_item(item6,  4)279            order.add_item(item7,  3)280            order.add_item(item8,  4)281            order.add_item(item10, 8)282            total = order.calculate_total()283            self.assertEqual(total, 110.03)284        def create_item(self, name, price, billing_method, special, datastore):285            item = Item(name, price, billing_method, special)286            datastore.set('itemdetails:' + name, item)287            return item288        def create_order(self, datastore):289            order = MakeOrder(self.order_id, datastore)290            datastore.set('orders:' + order.order_id, order)291            return order...calculatebestsavingstests.py
Source:calculatebestsavingstests.py  
...16                'off': 5017            }18            19            datastore = DataStore()20            item = self.create_item('test', 5.00, 'unit', special, datastore)21            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 1}, dict(), datastore)22            self.assertEqual(savings, (0, []))23        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_1_amount_limit_1_returns_0(self):24            special = {25                'type': 'buyAgetBforCoff',26                'buy': 1,27                'get': 2,28                'off': 50,29                'limit': 230            }31            32            datastore = DataStore()33            item = self.create_item('test', 5.00, 'unit', special, datastore)34            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 1}, dict(), datastore)35            self.assertEqual(savings, (0, []))36        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_5_amount_returns_correct_savings(self):37            special = {38                'type': 'buyAgetBforCoff',39                'buy': 1,40                'get': 2,41                'off': 5042            }43            44            datastore = DataStore()45            item = self.create_item('test', 5.00, 'unit', special, datastore)46            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 5}, dict(), datastore)47            self.assertEqual(savings, (5.0, [{'identifier': 'test', 'quantity': 3}]))48        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_buy_1_get_2_50_off(self):49            special = {50                'type': 'buyAgetBforCoff',51                'buy': 1,52                'get': 2,53                'off': 5054            }55            datastore = DataStore()56            item = self.create_item('test', 5.00, 'unit', special, datastore)57            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 6}, dict(), datastore)58            self.assertEqual(savings, (10.0, [{'identifier': 'test', 'quantity': 6}]))59        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_buy_2_get_1_free(self):60            special = {61                'type': 'buyAgetBforCoff',62                'buy': 2,63                'get': 1,64                'off': 10065            }66            datastore = DataStore()67            item = self.create_item('test', 6.00, 'unit', special, datastore)68            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 2}, dict(), datastore)69            self.assertEqual(savings, (0, []))70        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_buy_2_get_1_free_1_occurrence(self):71            special = {72                'type': 'buyAgetBforCoff',73                'buy': 2,74                'get': 1,75                'off': 10076            }77            datastore = DataStore()78            item = self.create_item('test', 6.00, 'unit', special, datastore)79            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 3}, dict(), datastore)80            self.assertEqual(savings, (6.0, [{'identifier': 'test', 'quantity': 3}]))81        def test_calculate_best_savings_for_BuyAgetBforCoff_for_item_with_buy_2_get_1_free_2_occurrences(self):82            special = {83                'type': 'buyAgetBforCoff',84                'buy': 2,85                'get': 1,86                'off': 10087            }88            datastore = DataStore()89            item = self.create_item('test', 6.00, 'unit', special, datastore)90            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 7}, dict(), datastore)91            self.assertEqual(savings, (12.0, [{'identifier': 'test', 'quantity': 6}]))92        def test_calculate_best_savings_for_BuyAgetBforCoff_for_buy_1_get_1_free_limit_2_with_10_items(self):93            special = {94                'type': 'buyAgetBforCoff',95                'buy': 1,96                'get': 1,97                'off': 100,98                'limit': 299            }100            datastore = DataStore()101            item = self.create_item('test', 5.00, 'unit', special, datastore)102            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 10}, dict(), datastore)103            self.assertEqual(savings, (5.0, [{'identifier': 'test', 'quantity': 2}]))104        def test_calculate_best_savings_for_BuyAgetBforCoff_for_buy_1_get_1_free_limit_3_with_10_items(self):105            special = {106                'type': 'buyAgetBforCoff',107                'buy': 1,108                'get': 1,109                'off': 100,110                'limit': 3111            }112            datastore = DataStore()113            item = self.create_item('test', 5.00, 'unit', special, datastore)114            savings = item.special.calculate_best_savings({'identifier': 'test', 'quantity': 10}, dict(), datastore)115            self.assertEqual(savings, (5.0, [{'identifier': 'test', 'quantity': 2}]))116        def test_calculate_best_savings_for_GetEOLforAoff_with_10_dollar_meat_and_9_dollar_other_item(self):117            special = {118                'type': 'getEOLforAoff',119                'off': 50120            }121            datastore = DataStore()122            item  = self.create_item('meat', 5.00, 'weight', special, datastore)123            item2 = self.create_item('soup', 4.50, 'unit', None, datastore)124            125            savings = item.special.calculate_best_savings({'identifier': 'meat', 'quantity': 2}, {'soup': 2}, datastore)126            self.assertEqual(savings, (2.25, [{'identifier': 'soup', 'quantity': 1}, {'identifier': 'meat', 'quantity': 2}]))127        def test_calculate_best_savings_for_GetEOLforAoff_with_10_dollar_meat_and_15_dollar_other_items(self):128            special = {129                'type': 'getEOLforAoff',130                'off': 50131            }132            datastore = DataStore()133            item  = self.create_item('meat', 5.00, 'weight', special, datastore)134            item2 = self.create_item('soup', 5.00, 'unit', None, datastore)135            savings = item.special.calculate_best_savings({'identifier': 'meat', 'quantity': 2}, {'soup': 3}, datastore)136            self.assertEqual(savings, (2.50, [{'identifier': 'soup', 'quantity': 1}, {'identifier': 'meat', 'quantity': 2}]))137        def test_calculate_best_savings_for_GetEOLforAoff_with_10_dollar_meat_and_15_dollar_other_single_item(self):138            special = {139                'type': 'getEOLforAoff',140                'off': 50141            }142            datastore = DataStore()143            item  = self.create_item('meat', 5.00, 'weight', special, datastore)144            item2 = self.create_item('soup', 15.00, 'unit', None, datastore)145            savings = item.special.calculate_best_savings({'identifier': 'meat', 'quantity': 2}, {'soup': 1}, datastore)146            self.assertEqual(savings, (0.00, []))147        def test_calculate_best_savings_for_GetEOLforAoff_with_10_dollar_meat_and_15_dollar_two_other_items(self):148            special = {149                'type': 'getEOLforAoff',150                'off': 50151            }152            datastore = DataStore()153            item  = self.create_item('meat', 5.00, 'weight', special, datastore)154            item2 = self.create_item('soup', 10.00, 'unit', None, datastore)155            item3 = self.create_item('pasta', 1.00, 'unit', None, datastore)156            savings = item.special.calculate_best_savings({'identifier': 'meat', 'quantity': 2}, {'soup': 1, 'pasta': 15}, datastore)157            self.assertEqual(savings, (5.00, [{'identifier': 'soup', 'quantity': 1}, {'identifier': 'meat', 'quantity': 2}]))158        def test_calculate_best_savings_for_AforB_with_2_for_5_with_2_items(self):159            special = {160                'type': 'AforB',161                'buy': 2,162                'for': 5.00163            }164            datastore = DataStore()165            item  = self.create_item('soup', 3.00, 'unit', special, datastore)166            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 2}, dict(), datastore)167            self.assertEqual(savings, (1.00, [{'identifier': 'soup', 'quantity': 2}]))168        def test_calculate_best_savings_for_AforB_with_5_for_5_with_10_items(self):169            special = {170                'type': 'AforB',171                'buy': 5,172                'for': 5.00173            }174            datastore = DataStore()175            item  = self.create_item('soup', 2.00, 'unit', special, datastore)176            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 10}, dict(), datastore)177            self.assertEqual(savings, (10.00, [{'identifier': 'soup', 'quantity': 10}]))178        def test_calculate_best_savings_for_AforB_with_5_for_5_with_15_items_and_limit_10(self):179            special = {180                'type': 'AforB',181                'buy': 5,182                'for': 5.00,183                'limit': 10184            }185            datastore = DataStore()186            item  = self.create_item('soup', 2.00, 'unit', special, datastore)187            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 10}, dict(), datastore)188            self.assertEqual(savings, (10.00, [{'identifier': 'soup', 'quantity': 10}]))189        def test_calculate_best_savings_for_AforB_with_5_for_5_with_8_items_and_limit_10(self):190            special = {191                'type': 'AforB',192                'buy': 5,193                'for': 5.00,194                'limit': 10195            }196            datastore = DataStore()197            item  = self.create_item('soup', 2.00, 'unit', special, datastore)198            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 8}, dict(), datastore)199            self.assertEqual(savings, (5.00, [{'identifier': 'soup', 'quantity': 5}]))200        def test_calculate_best_savings_for_AforB_with_10_for_5_with_9_items_returns_0(self):201            special = {202                'type': 'AforB',203                'buy': 10,204                'for': 5.00,205            }206            datastore = DataStore()207            item  = self.create_item('soup', 2.00, 'unit', special, datastore)208            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 9}, dict(), datastore)209            self.assertEqual(savings, (0.00, []))210        def test_calculate_best_savings_for_AforB_with_10_for_5_with_9_items_limit_5_returns_0(self):211            special = {212                'type': 'AforB',213                'buy': 10,214                'for': 5.00,215                'limit': 5216            }217            datastore = DataStore()218            item  = self.create_item('soup', 2.00, 'unit', special, datastore)219            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 9}, dict(), datastore)220            self.assertEqual(savings, (0.00, []))221        def test_calculate_best_savings_for_AforB_with_5_for_5_with_9_items_limit_5_returns_0(self):222            special = {223                'type': 'AforB',224                'buy': 5,225                'for': 5.00,226                'limit': 5227            }228            datastore = DataStore()229            item  = self.create_item('soup', 2.00, 'unit', special, datastore)230            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 9}, dict(), datastore)231            self.assertEqual(savings, (5.00, [{'identifier': 'soup', 'quantity': 5}]))232        def test_calculate_best_savings_for_markdown_with_50_off_with_2_items(self):233            special = {234                'type': 'markdown',235                'price': 1.00236            }237            datastore = DataStore()238            item  = self.create_item('soup', 2.00, 'unit', special, datastore)239            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 2}, dict(), datastore)240            self.assertEqual(savings, (2.00, [{'identifier': 'soup', 'quantity': 2}]))241        def test_calculate_best_savings_for_markdown_with_50_off_with_4_items_with_limit_2(self):242            special = {243                'type': 'markdown',244                'price': 1.00,245                'limit': 2246            }247            datastore = DataStore()248            item  = self.create_item('soup', 2.00, 'unit', special, datastore)249            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 4}, dict(), datastore)250            self.assertEqual(savings, (2.00, [{'identifier': 'soup', 'quantity': 2}]))251        def test_calculate_best_savings_for_markdown_with_100_off_with_5_items_with_limit_5(self):252            special = {253                'type': 'markdown',254                'price': 2.00,255                'limit': 5256            }257            datastore = DataStore()258            item  = self.create_item('soup', 2.00, 'unit', special, datastore)259            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 5}, dict(), datastore)260            self.assertEqual(savings, (10.00, [{'identifier': 'soup', 'quantity': 5}]))261        def test_calculate_best_savings_for_markdown_with_0_off_with_5_items_with_limit_5(self):262            special = {263                'type': 'markdown',264                'price': 0.00,265                'limit': 5266            }267            datastore = DataStore()268            item  = self.create_item('soup', 2.00, 'unit', special, datastore)269            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 5}, dict(), datastore)270            self.assertEqual(savings, (0.00, [{'identifier': 'soup', 'quantity': 5}]))271        def test_calculate_best_savings_for_markdown_with_25_off_with_5_items_with_limit_1(self):272            special = {273                'type': 'markdown',274                'price': 0.50,275                'limit': 1276            }277            datastore = DataStore()278            item  = self.create_item('soup', 2.00, 'unit', special, datastore)279            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 5}, dict(), datastore)280            self.assertEqual(savings, (0.50, [{'identifier': 'soup', 'quantity': 1}]))281        def test_calculate_best_savings_for_markdown_with_25_off_with_5_items_with_limit_6(self):282            special = {283                'type': 'markdown',284                'price': 0.50,285                'limit': 6286            }287            datastore = DataStore()288            item  = self.create_item('soup', 2.00, 'unit', special, datastore)289            savings = item.special.calculate_best_savings({'identifier': 'soup', 'quantity': 5}, dict(), datastore)290            self.assertEqual(savings, (2.50, [{'identifier': 'soup', 'quantity': 5}]))291        def create_item(self, name, price, billing_method, special, datastore):292            item = Item(name, price, billing_method, special)293            datastore.set('itemdetails:' + name, item)294            return item...meso.py
Source:meso.py  
...7        if self.user_detected(boxIds=[301]):8            return ìë£(self.ctx)9class ìë£(common.Trigger):10    def on_enter(self):11        self.create_item(spawnIds=[201])12        self.create_item(spawnIds=[202])13        self.create_item(spawnIds=[203])14        self.create_item(spawnIds=[204])15        self.create_item(spawnIds=[205])16        self.create_item(spawnIds=[206])17        self.create_item(spawnIds=[207])18        self.create_item(spawnIds=[208])19        self.create_item(spawnIds=[209])20        self.create_item(spawnIds=[210])21        self.create_item(spawnIds=[211])22        self.create_item(spawnIds=[212])23        self.create_item(spawnIds=[213])24        self.create_item(spawnIds=[214])25        self.create_item(spawnIds=[215])26        self.create_item(spawnIds=[216])27        self.create_item(spawnIds=[217])28        self.create_item(spawnIds=[218])29        self.create_item(spawnIds=[219])30        self.create_item(spawnIds=[220])31        self.create_item(spawnIds=[221])32        self.create_item(spawnIds=[222])33        self.create_item(spawnIds=[223])34        self.create_item(spawnIds=[224])35        self.create_item(spawnIds=[225])36        self.create_item(spawnIds=[226])37        self.create_item(spawnIds=[227])38        self.create_item(spawnIds=[228])39        self.create_item(spawnIds=[229])40        self.create_item(spawnIds=[230])41        self.create_item(spawnIds=[231])42        self.create_item(spawnIds=[232])43        self.create_item(spawnIds=[233])44        self.create_item(spawnIds=[234])45        self.create_item(spawnIds=[235])46        self.create_item(spawnIds=[236])47        self.create_item(spawnIds=[237])48        self.create_item(spawnIds=[238])49        self.create_item(spawnIds=[239])50        self.create_item(spawnIds=[240])51        self.create_item(spawnIds=[241])52        self.create_item(spawnIds=[242])53        self.create_item(spawnIds=[243])54        self.create_item(spawnIds=[244])55        self.create_item(spawnIds=[245])56        self.create_item(spawnIds=[246])57        self.create_item(spawnIds=[247])58        self.create_item(spawnIds=[248])59        self.create_item(spawnIds=[249])60        self.create_item(spawnIds=[250])61        self.create_item(spawnIds=[251])62        self.create_item(spawnIds=[252])63        self.create_item(spawnIds=[253])64        self.create_item(spawnIds=[254])65        self.create_item(spawnIds=[255])66        self.create_item(spawnIds=[256])67        self.create_item(spawnIds=[257])68        self.create_item(spawnIds=[258])69        self.create_item(spawnIds=[259])70        self.create_item(spawnIds=[260])71        self.create_item(spawnIds=[261])72        self.create_item(spawnIds=[262])73        self.create_item(spawnIds=[263])74        self.create_item(spawnIds=[264])75        self.create_item(spawnIds=[265])76        self.create_item(spawnIds=[266])77        self.create_item(spawnIds=[267])78        self.create_item(spawnIds=[268])79        self.create_item(spawnIds=[269])80        self.create_item(spawnIds=[270])81        self.create_item(spawnIds=[9001,9002,9003,9004,9005])82        self.set_timer(timerId='1', seconds=2)83    def on_tick(self) -> common.Trigger:84        if self.time_expired(timerId='1'):85            return ìë£2(self.ctx)86class ìë£2(common.Trigger):87    def on_enter(self):88        self.set_mesh(triggerIds=[101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154], visible=False)...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!!
