Ejemplo n.º 1
0
    def test_budget_argument_is_not_a_budget_instance(self):
        """testing if a TypeError will be raised if the budget argument is not
        a Budget instance
        """
        with self.assertRaises(TypeError) as cm:
            BudgetEntry(budget='not a budget', amount=10.0)

        self.assertEqual(
            str(cm.exception),
            'BudgetEntry.budget should be a Budget instance, not str')
Ejemplo n.º 2
0
    def test_price_argument_is_not_a_number(self):
        """testing if a TypeError will be raised if the price argument is set
        to something other than a number
        """
        with pytest.raises(TypeError) as cm:
            BudgetEntry(budget=self.test_budget,
                        good=self.test_good,
                        price='some string')

        assert str(cm.value) == 'BudgetEntry.price should be a number, not str'
Ejemplo n.º 3
0
 def test_price_attribute_is_working_properly(self):
     """testing if the price attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         price=10)
     test_value = 5.0
     assert entry.price != test_value
     entry.price = test_value
     assert entry.price == test_value
Ejemplo n.º 4
0
 def test_cost_attribute_is_set_to_None(self):
     """testing if the cost attribute will be set to 0 if it is set to None
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     assert entry.cost == self.test_good.cost
     entry.cost = None
     assert entry.cost == 0.0
Ejemplo n.º 5
0
 def test_price_attribute_is_set_to_None(self):
     """testing if the price attribute will be set to 0 if price attribute
     is set to None
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         price=10.0)
     assert entry.price == 10.0
     entry.price = None
     assert entry.price == 0.0
Ejemplo n.º 6
0
 def test_amount_attribute_is_set_to_None(self):
     """testing if the amount attribute will be set to 0 if it is set to
     None
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         amount=10.0)
     assert entry.amount == 10.0
     entry.amount = None
     assert entry.amount == 0.0
Ejemplo n.º 7
0
    def test_good_argument_is_skipped(self):
        """testing if a TypeError will be raised when the good argument is
        skipped
        """
        with pytest.raises(TypeError) as cm:
            BudgetEntry(budget=self.test_budget)

        assert str(cm.value) == \
            'BudgetEntry.good should be a stalker.models.budget.Good ' \
            'instance, not NoneType'
Ejemplo n.º 8
0
 def test_amount_attribute_is_working_properly(self):
     """testing if the amount attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         amount=10)
     test_value = 5.0
     self.assertNotEqual(entry.amount, test_value)
     entry.amount = test_value
     self.assertEqual(entry.amount, test_value)
Ejemplo n.º 9
0
 def test_good_argument_is_skipped(self):
     """testing if a TypeError will be raised when the good argument is
     skipped
     """
     with self.assertRaises(TypeError) as cm:
         entry = BudgetEntry(budget=self.test_budget, )
     self.assertEqual(
         str(cm.exception),
         'BudgetEntry.good should be a stalker.models.budget.Good instance,'
         ' not NoneType')
Ejemplo n.º 10
0
 def test_realized_total_attribute_is_working_properly(self):
     """testing if the realized_total attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         realized_total=10)
     test_value = 5.0
     self.assertNotEqual(entry.realized_total, test_value)
     entry.realized_total = test_value
     self.assertEqual(entry.realized_total, test_value)
Ejemplo n.º 11
0
    def test_unit_attribute_is_not_a_string(self):
        """testing if a TypeError will be raised if the unit attribute is set
        to something other than a string
        """
        entry = BudgetEntry(budget=self.test_budget, good=self.test_good)
        with self.assertRaises(TypeError) as cm:
            entry.unit = 100.212

        self.assertEqual(str(cm.exception),
                         'BudgetEntry.unit should be a string, not float')
Ejemplo n.º 12
0
 def test_price_attribute_is_working_properly(self):
     """testing if the price attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         price=10)
     test_value = 5.0
     self.assertNotEqual(entry.price, test_value)
     entry.price = test_value
     self.assertEqual(entry.price, test_value)
Ejemplo n.º 13
0
 def test_cost_attribute_is_set_to_None(self):
     """testing if the cost attribute will be set to 0 if it is set to None
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     self.assertEqual(entry.cost, self.test_good.cost)
     entry.cost = None
     self.assertEqual(entry.cost, 0.0)
Ejemplo n.º 14
0
 def test_budget_attribute_is_working_properly(self):
     """testing if the budget attribute value can correctly be changed
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         amount=10.0)
     new_budget = Budget(name='Test Budget', project=self.test_project)
     self.assertNotEqual(entry.budget, new_budget)
     entry.budget = new_budget
     self.assertEqual(entry.budget, new_budget)
Ejemplo n.º 15
0
 def test_realized_total_attribute_is_working_properly(self):
     """testing if the realized_total attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         realized_total=10)
     test_value = 5.0
     assert entry.realized_total != test_value
     entry.realized_total = test_value
     assert entry.realized_total == test_value
Ejemplo n.º 16
0
 def test_good_attribute_is_working_properly(self):
     """testing if the good attribute can be correctly set
     """
     test_value = Good(name='Some Other Good')
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         amount=53)
     self.assertNotEqual(entry.good, test_value)
     entry.good = test_value
     self.assertEqual(entry.good, test_value)
Ejemplo n.º 17
0
    def test_unit_attribute_is_not_a_string(self):
        """testing if a TypeError will be raised if the unit attribute is set
        to something other than a string
        """
        entry = BudgetEntry(budget=self.test_budget, good=self.test_good)
        with pytest.raises(TypeError) as cm:
            entry.unit = 100.212

        assert str(cm.value) == \
            'BudgetEntry.unit should be a string, not float'
Ejemplo n.º 18
0
    def test_entries_attribute_is_working_properly(self):
        """testing if the entries attribute is working properly
        """
        from stalker import BudgetEntry
        some_other_budget = Budget(name='Test Budget',
                                   project=self.test_project,
                                   status_list=self.budget_status_list)
        entry1 = BudgetEntry(
            budget=some_other_budget,
            good=self.test_good,
        )
        entry2 = BudgetEntry(
            budget=some_other_budget,
            good=self.test_good,
        )

        self.test_budget.entries = [entry1, entry2]

        assert self.test_budget.entries == [entry1, entry2]
Ejemplo n.º 19
0
 def test_amount_attribute_is_working_properly(self):
     """testing if the amount attribute is working properly
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         amount=10)
     test_value = 5.0
     assert entry.amount != test_value
     entry.amount = test_value
     assert entry.amount == test_value
Ejemplo n.º 20
0
 def test_realized_total_attribute_is_set_to_None(self):
     """testing if the realized_total attribute will be set to 0 if it is
     set to None
     """
     entry = BudgetEntry(budget=self.test_budget,
                         good=self.test_good,
                         realized_total=10.0)
     assert entry.realized_total == 10.0
     entry.realized_total = None
     assert entry.realized_total == 0.0
Ejemplo n.º 21
0
    def test_budget_argument_is_skipped(self):
        """testing if a TypeError will be raised if the budget argument is
        skipped
        """
        with self.assertRaises(TypeError) as cm:
            BudgetEntry(amount=10.0)

        self.assertEqual(
            str(cm.exception),
            'BudgetEntry.budget should be a Budget instance, not NoneType')
Ejemplo n.º 22
0
 def test_msrp_attribute_is_working_properly(self):
     """testing if the msrp attribute is working properly
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     test_value = 5.0
     self.assertNotEqual(entry.msrp, test_value)
     entry.msrp = test_value
     self.assertEqual(entry.msrp, test_value)
Ejemplo n.º 23
0
 def test_good_argument_is_working_properly(self):
     """testing if the good argument value is correctly passed to the good
     attribute
     """
     test_value = Good(name='Some Good')
     entry = BudgetEntry(
         budget=self.test_budget,
         good=test_value,
         amount=53,
     )
     self.assertEqual(entry.good, test_value)
Ejemplo n.º 24
0
    def test_amount_argument_is_not_a_number(self):
        """testing if a TypeError will be raised if the amount argument is set
        to something other than a number
        """
        with self.assertRaises(TypeError) as cm:
            BudgetEntry(budget=self.test_budget,
                        good=self.test_good,
                        amount='some string')

        self.assertEqual(str(cm.exception),
                         'BudgetEntry.amount should be a number, not str')
Ejemplo n.º 25
0
 def test_msrp_attribute_is_set_to_None(self):
     """testing if the msrp attribute will be set to 0 if msrp attribute is
     set to None
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     self.assertEqual(entry.msrp, self.test_good.msrp)
     entry.msrp = None
     self.assertEqual(entry.msrp, 0.0)
Ejemplo n.º 26
0
    def test_realized_total_argument_is_not_a_number(self):
        """testing if a TypeError will be raised if the realized_total argument
        is set to something other than a number
        """
        with pytest.raises(TypeError) as cm:
            BudgetEntry(budget=self.test_budget,
                        good=self.test_good,
                        realized_total='some string')

        assert str(cm.value) == \
            'BudgetEntry.realized_total should be a number, not str'
Ejemplo n.º 27
0
    def test_price_attribute_is_not_a_number(self):
        """testing if a TypeError will be raised if price attribute is set to
        something other than a number
        """
        entry = BudgetEntry(budget=self.test_budget,
                            good=self.test_good,
                            price=10)
        with pytest.raises(TypeError) as cm:
            entry.price = 'some string'

        assert str(cm.value) == 'BudgetEntry.price should be a number, not str'
Ejemplo n.º 28
0
 def test_msrp_attribute_is_working_properly(self):
     """testing if the msrp attribute is working properly
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     test_value = 5.0
     assert entry.msrp != test_value
     entry.msrp = test_value
     assert entry.msrp == test_value
Ejemplo n.º 29
0
 def test_msrp_attribute_is_set_to_None(self):
     """testing if the msrp attribute will be set to 0 if msrp attribute is
     set to None
     """
     entry = BudgetEntry(
         budget=self.test_budget,
         good=self.test_good,
     )
     assert entry.msrp == self.test_good.msrp
     entry.msrp = None
     assert entry.msrp == 0.0
Ejemplo n.º 30
0
    def test_price_attribute_is_not_a_number(self):
        """testing if a TypeError will be raised if price attribute is set to
        something other than a number
        """
        entry = BudgetEntry(budget=self.test_budget,
                            good=self.test_good,
                            price=10)
        with self.assertRaises(TypeError) as cm:
            entry.price = 'some string'

        self.assertEqual(str(cm.exception),
                         'BudgetEntry.price should be a number, not str')