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_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