Esempio n. 1
0
    def test_product_add_merchant(self):
        product = self.product
        merchant = Merchant('test merchant')
        product.add_merchant(merchant)
        transaction.commit()
        self.keeper.close()

        self.keeper = open_storage()
        product = Product.fetch(u'Молоко Great Milk 1L', self.keeper)
        self.assertIn(merchant, product.merchants)
Esempio n. 2
0
 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)
Esempio n. 3
0
    def test_product_add_report(self):
        product = self.product
        product.category = self.category
        report1 = PriceReport(
            price_value=42.6,
            product=product,
            reporter=Reporter('Jill'),
            merchant=Merchant("Scotty's grocery"),
        )
        product.add_report(report1)
        product.add_report(report1)
        transaction.commit()
        self.keeper.close()

        self.keeper = open_storage()
        product = Product.fetch(u'Молоко Great Milk 1L', self.keeper)
        self.assertIn(report1, product.reports)
        self.assertEqual(1, len(product.reports))