def build_beverages(self): cat = CatalogCategory() cat.name = 'Beverages' co = CatalogObject() co.type = 'CATEGORY' co.id = self.CLIENT_ID_BEVERAGES co.category_data = cat return co
def test_upsert_catalog_object(self): obj = CatalogObject() obj.type = 'DISCOUNT' obj.id = self.CLIENT_ID_DISCOUNT discount = CatalogDiscount() discount.name = 'Half Off' discount.percentage = '50.0' obj.discount_data = discount req = UpsertCatalogObjectRequest(str(uuid.uuid4()), obj) res = self.api.upsert_catalog_object(req) self.assertEqual('Half Off', res.catalog_object.discount_data.name) self.assertIsNotNone(res.catalog_object.id) self.assertIsNotNone(res.catalog_object.updated_at) self.assertIsNotNone(res.catalog_object.version) self.assertIsNotNone(res.catalog_object.is_deleted)
def build_sales_tax(self): co = CatalogObject() co.type = 'TAX' co.id = self.CLIENT_ID_SALES_TAX co.present_at_all_locations = True t = CatalogTax() t.name = 'Sales Tax' t.calculation_phase = 'TAX_SUBTOTAL_PHASE' t.inclusion_type = 'ADDITIVE' t.percentage = '5.0' t.applies_to_custom_amounts = True t.enabled = True co.tax_data = t return co
def test_batch_upsert_catalog_objects(self): batches = [] num_objects = 0 for batch_num in range(3): objects = [] batch = CatalogObjectBatch(objects) batches.append(batch) for i in range(100): item_id = '#Items-{}-{}'.format(batch_num, i) variation_id = '#ItemVariation-{}-{}'.format(batch_num, i) item = CatalogObject() item.type = 'ITEM' item.id = item_id item_data = CatalogItem() item_data.name = 'Item-{}-{}'.format(batch_num, i) item.item_data = item_data variation = CatalogObject() variation.type = 'VARIATION' variation.id = variation_id variation_data = CatalogItemVariation() variation_data.item_id = item_id variation_data.name = 'Regular' variation_data.pricing_type = 'VARIABLE_PRICING' variation.item_variation_data = variation_data objects.append(item) num_objects += 1 req = BatchUpsertCatalogObjectsRequest(str(uuid.uuid4()), batches) res = self.api.batch_upsert_catalog_objects(req) self.assertIsNone(res.errors) self.assertEquals(num_objects, len(res.objects))
def build_milks(self): whmm = CatalogModifier() whmm.name = 'Whole Milk' whm = CatalogObject() whm.type = 'MODIFIER' whm.id = self.CLIENT_ID_MILK_WHOLE whm.modifier_data = whmm skmm = CatalogModifier() skmm.name = 'Skim Milk' skm = CatalogObject() skm.type = 'MODIFIER' skm.id = self.CLIENT_ID_MILK_SKIM skm.modifier_data = skmm symm = CatalogModifier() symm.name = 'Soy Milk' symm.price_money = Money(50, 'USD') sym = CatalogObject() sym.type = 'MODIFIER' sym.id = self.CLIENT_ID_MILK_SOY sym.modifier_data = symm ml = CatalogModifierList() ml.name = 'Milks' ml.modifiers = [whm, skm, sym] co = CatalogObject() co.type = 'MODIFIER_LIST' co.id = self.CLIENT_ID_MILKS co.modifier_list_data = ml return co
def build_tea(self): c = CatalogObject() c.type = 'ITEM' c.id = self.CLIENT_ID_TEA c.present_at_all_locations = True stiv = CatalogItemVariation() stiv.item_id = c.id stiv.name = 'Small' stiv.pricing_type = 'FIXED_PRICING' stiv.price_money = Money(150, 'USD') st = CatalogObject() st.type = 'ITEM_VARIATION' st.id = self.CLIENT_ID_TEA_SMALL st.present_at_all_locations = True st.item_variation_data = stiv ltiv = CatalogItemVariation() ltiv.item_id = c.id ltiv.name = 'Large' ltiv.pricing_type = 'FIXED_PRICING' ltiv.price_money = Money(200, 'USD') lt = CatalogObject() lt.type = 'ITEM_VARIATION' lt.id = self.CLIENT_ID_TEA_LARGE lt.present_at_all_locations = True lt.item_variation_data = ltiv cimli = CatalogItemModifierListInfo() cimli.modifier_list_id = self.CLIENT_ID_MILKS ci = CatalogItem() ci.name = 'Tea' ci.description = 'Hot leaf juice' ci.abbreviation = 'Te' ci.category_id = self.CLIENT_ID_BEVERAGES ci.modifier_list_info = [cimli] ci.tax_ids = [self.CLIENT_ID_SALES_TAX] ci.variations = [st, lt] c.item_data = ci return c
def build_coffee(self): c = CatalogObject() c.type = 'ITEM' c.id = self.CLIENT_ID_COFFEE c.present_at_all_locations = True sciv = CatalogItemVariation() sciv.item_id = c.id sciv.name = 'Small' sciv.pricing_type = 'FIXED_PRICING' sciv.price_money = Money(195, 'USD') sc = CatalogObject() sc.type = 'ITEM_VARIATION' sc.id = self.CLIENT_ID_COFFEE_SMALL sc.present_at_all_locations = True sc.item_variation_data = sciv lciv = CatalogItemVariation() lciv.item_id = c.id lciv.name = 'Large' lciv.pricing_type = 'FIXED_PRICING' lciv.price_money = Money(250, 'USD') lc = CatalogObject() lc.type = 'ITEM_VARIATION' lc.id = self.CLIENT_ID_COFFEE_LARGE lc.present_at_all_locations = True lc.item_variation_data = lciv cimli = CatalogItemModifierListInfo() cimli.modifier_list_id = self.CLIENT_ID_MILKS ci = CatalogItem() ci.name = 'Coffee' ci.description = 'Hot bean juice' ci.abbreviation = 'Co' ci.category_id = self.CLIENT_ID_BEVERAGES ci.modifier_list_info = [cimli] ci.tax_ids = [self.CLIENT_ID_SALES_TAX] ci.variations = [sc, lc] c.item_data = ci return c
def build_syrups(self): hzmm = CatalogModifier() hzmm.name = 'Hazelnut' hzm = CatalogObject() hzm.type = 'MODIFIER' hzm.id = self.CLIENT_ID_HAZELNUT hzm.modifier_data = hzmm vnmm = CatalogModifier() vnmm.name = 'Vanilla' vnm = CatalogObject() vnm.type = 'MODIFIER' vnm.id = self.CLIENT_ID_VANILLA vnm.modifier_data = vnmm chmm = CatalogModifier() chmm.name = 'Chocolate' chm = CatalogObject() chm.type = 'MODIFIER' chm.id = self.CLIENT_ID_CHOCOLATE chm.modifier_data = chmm ml = CatalogModifierList() ml.name = 'Syrups' ml.modifiers = [hzm, vnm, chm] co = CatalogObject() co.type = 'MODIFIER_LIST' co.id = self.CLIENT_ID_SYRUPS co.modifier_list_data = ml return co