Пример #1
0
 def test_client_attribute_is_working_properly(self):
     """testing if the client attribute value an be changed properly
     """
     from stalker import Invoice
     test_invoice = Invoice(budget=self.test_budget,
                            client=self.test_client,
                            amount=100,
                            unit='TRY')
     from stalker import Client
     test_client = Client(name='Test Client 2')
     self.assertNotEqual(test_invoice.client, test_client)
     test_invoice.client = test_client
     self.assertEqual(test_invoice.client, test_client)
Пример #2
0
    def test_client_attribute_is_set_to_None(self):
        """testing if a TypeError will be raised when the client attribute is
        set to None
        """
        from stalker import Invoice
        test_invoice = Invoice(budget=self.test_budget,
                               client=self.test_client,
                               amount=100,
                               unit='TRY')
        with pytest.raises(TypeError) as cm:
            test_invoice.client = None

        assert str(cm.value) == \
            'Invoice.client should be a Client instance, not NoneType'
Пример #3
0
    def test_client_attribute_is_set_to_a_value_other_than_a_client_instance(
            self):
        """testing if a TypeError will be raised when the client attribute is
        set to a value other than a Client instance
        """
        from stalker import Invoice
        test_invoice = Invoice(budget=self.test_budget,
                               client=self.test_client,
                               amount=100,
                               unit='TRY')
        with self.assertRaises(TypeError) as cm:
            test_invoice.client = 'not a client instance'

        self.assertEqual(
            str(cm.exception),
            'Invoice.client should be a Client instance, not str')