Exemplo n.º 1
0
    def setUp(self):
        self.stuff = FoodStuff(name='some stuff 3')
        self.stuff.save()

        recipe = Recipe(name='some recipe 3')
        recipe.save()

        ingredient = RecipeIngredient(
            stuff  = self.stuff,
            recipe = recipe,
            count  = 1.5
        )
        ingredient.save()

        self.product = Product(
            name   = 'some product 3',
            recipe = recipe,
            markup = 1.5
        )
        self.product.save()

        provider = FoodProvider(name='some provider')
        provider.save()

        purchase = Purchase(
            provider   = provider,
            stuff      = self.stuff,
            cost       = 200,
            unit_count = 10,
            unit_size  = 1,
        )
        purchase.save()

        self.offer = SaleOffer(product=self.product)
        self.offer.save()
Exemplo n.º 2
0
    def setUp(self):
        stuff = FoodStuff(name='some stuff 2')
        stuff.save()

        recipe = Recipe(name='some recipe 2')
        recipe.save()

        ingredient = RecipeIngredient(stuff=stuff, recipe=recipe, count=1.5)
        ingredient.save()

        self.product = Product(name='some product 2', recipe=recipe)
        self.product.save()
Exemplo n.º 3
0
    def test_str(self):
        stuff = FoodStuff(name='some stuff')
        stuff.save()

        recipe = Recipe(name='some recipe')
        recipe.save()

        ingredient = RecipeIngredient(
            stuff  = stuff,
            recipe = recipe,
            count  = 1.5
        )
        ingredient.save()

        self.assertEqual('some stuff x 1.5', str(ingredient))
Exemplo n.º 4
0
class CalculationTests(TestCase):
    def setUp(self):
        self.stuff = FoodStuff(name='some stuff 4')
        self.stuff.save()

        recipe = Recipe(name='some recipe 4')
        recipe.save()

        self.ingredient = RecipeIngredient(
            stuff  = self.stuff,
            recipe = recipe,
            count  = 1.5
        )
        self.ingredient.save()

        self.product = Product(name='some product 4', recipe=recipe)
        self.product.save()

        self.offer = SaleOffer(product=self.product)
        self.offer.save()

    def test_create_with_only_material_count(self):
        check = Calculation.create(self.offer, self.ingredient)
        self.assertEqual(1.5, check.material_count)
        self.assertFalse(check.feasible)
        self.assertEqual(0, check.monetary_count)

    def test_create(self):
        provider = FoodProvider(name='some provider')
        provider.save()

        purchase = Purchase(
            provider   = provider,
            stuff      = self.stuff,
            cost       = 200,
            unit_count = 10,
            unit_size  = 1,
        )
        purchase.save()

        check = Calculation.create(self.offer, self.ingredient)
        self.assertEqual(1.5, check.material_count)
        self.assertTrue(check.feasible)
        self.assertEqual(30, check.monetary_count)