from comptabilite.models import Transaction, TransactionType, Annuality def test_annuality_str(): """ """ new_annuality = Annuality(year="01/01/2016", opening_balance=5, closing_balance=10) assert "01/01/2016 (5 - 10)" == str(new_annuality) def test_transaction_str(): """ """ new_transaction = Transaction(description="test") assert "test" == str(new_transaction) def test_transaction_total_amount(): """ """ transaction_type = TransactionType( label="", category=0, order=0, transaction_type=1 ) new_transaction = Transaction( bkAmount=50, bxAmount=50, transaction_type=transaction_type ) assert 100 == new_transaction.total_amount # class TestModelTransaction(TestCase): # """Tests relatifs à la classe `BaseTransaction`.""" # def setUp(self): # self.transaction_type = TransactionType.objects.create( # label="", category=0, order=0, transaction_type=1 # ) # def test_compute_total_amount(self): # """ Vérifie que le calcul du montant total fonctionne correctement.""" # baseline = Transaction( # bkAmount=50, bxAmount=50, transaction_type=self.transaction_type # ) # baseline.save() # self.assertEqual(100, baseline.totalAmount) # def test_compute_amount(self): # """ Vérifie que le calcul du montant fonctionne correctement. """ # baseline = Transaction( # bkAmount=50, bxAmount=50, transaction_type=self.transaction_type # ) # baseline.save() # self.assertEqual(100, baseline.totalAmount) # self.assertEqual(100, baseline.amount) # def test_clean(self): # """ Vérifie que les contraintes de validation sont rencontrées. """ # c = Transaction( # transaction_type=self.transaction_type, bxAmount=None, bkAmount=None # ) # with self.assertRaises(ValidationError): # c.clean() # c1 = Transaction(transaction_type=self.transaction_type, bxAmount=50) # c1.save() # c2 = Transaction(transaction_type=self.transaction_type, bkAmount=50) # c2.save() # class TestTransactionType(TestCase): # """ Tests relatifs à la classe `TransactionType`. """ # def test_str_(self): # """Vérifie la représentation textuelle de la classe.""" # transaction_type = TransactionType(label="Test", transaction_type=1) # self.assertEqual("Test (Recette)", str(transaction_type))