def test_invoice_attribute_is_working_properly(self): """testing if the invoice attribute value can be correctly changed """ from stalker import Payment, Invoice p = Payment(invoice=self.test_invoice, amount=1499, unit='TRY') new_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=2500, unit='TRY') self.assertNotEqual(p.invoice, new_invoice) p.invoice = new_invoice self.assertEqual(p.invoice, new_invoice)
def test_invoice_attribute_is_None(self): """testing if a TypeError will be raised when the invoice attribute is set to None """ from stalker import Payment p = Payment(invoice=self.test_invoice, amount=1499, unit='TRY') with pytest.raises(TypeError) as cm: p.invoice = None assert str(cm.value) == \ 'Payment.invoice should be an Invoice instance, not NoneType'
def test_invoice_attribute_is_None(self): """testing if a TypeError will be raised when the invoice attribute is set to None """ from stalker import Payment p = Payment(invoice=self.test_invoice, amount=1499, unit='TRY') with self.assertRaises(TypeError) as cm: p.invoice = None self.assertEqual( str(cm.exception), 'Payment.invoice should be an Invoice instance, not NoneType')
def test_invoice_attribute_is_set_to_a_value_other_than_an_invoice_instance( self): """testing if a TypeError will be raised when the invoice attribute is set to a value other than an Invoice instance """ from stalker import Payment p = Payment(invoice=self.test_invoice, amount=1499, unit='TRY') with pytest.raises(TypeError) as cm: p.invoice = 'not an invoice instance' assert str(cm.value) == \ 'Payment.invoice should be an Invoice instance, not str'