def test_250g_comma_preceding(self): sour_cream025 = Product(u'Сметана Углече Поле органическая 15%, 250г') key = sour_cream025.get_category_key() sour_cream = ProductCategory(key) self.assertEqual('0.25 kg', sour_cream025.get_package_key()) self.assertEqual(0.625, sour_cream025.get_package().get_ratio(sour_cream))
def test_traverse_yaml(self): milk = ProductCategory('milk') self.assertEqual(u'молоко', milk.get_data('keyword').split(', ')[0]) self.assertEqual('diary', milk.get_category_key()) tuna = ProductCategory('tuna') self.assertEqual('fish', tuna.get_category_key()) chair = ProductCategory('chair') self.assertEqual('furniture', chair.get_category_key()) food = ProductCategory('food') self.assertEqual('product_categories', food.get_category_key()) root = ProductCategory('product_categories') self.assertIsNone(root.get_category_key())
def setUp(self): try: shutil.rmtree(STORAGE_DIR) except OSError: pass os.mkdir(STORAGE_DIR) self.keeper = open_storage() category = ProductCategory('milk') product = Product(u'Молоко Great Milk 1L') merchant = Merchant('test merchant') self.keeper.register(category, product, merchant) transaction.commit() self.keeper.close() self.keeper = open_storage() self.category = ProductCategory.fetch('milk', self.keeper) self.product = Product.fetch(u'Молоко Great Milk 1L', self.keeper) self.merchant = Merchant.fetch('test merchant', self.keeper)
def test_product_category_get_data(self): milk = ProductCategory('milk') self.assertEqual(1, milk.get_data('priority')) asp = ProductCategory('asparagus') self.assertEqual(0, asp.get_data('priority', default=0))
def setUp(self): self.milk = ProductCategory('milk')
def test_1_5kg(self): category = ProductCategory('rice') product = Product(u'Рис АГРОАЛЬЯНС краснодарский 1,5кг', category=category) self.assertEqual('1.5 kg', product.get_package_key())
def test_20pieces(self): egg = ProductCategory('chicken egg') product4_title = u'Яйцо динозавриное столовое, 20шт' self.assertEqual(2, Product(product4_title).get_package().get_ratio(egg))