Example #1
0
    def test_amount_due(self):
        contract = ContractFactory(amount=150, interest_rate=0)
        self.assertIsInstance(contract, Contract)

        PaymentFactory.create_batch(2, contract=contract, value=10)

        self.assertEqual(contract.amount_due, 130)
Example #2
0
    def test_list_success(self):
        contract = ContractFactory()
        PaymentFactory.create_batch(3, contract=contract)
        self.assertEqual(Payment.objects.count(), 3)
        self.set_user(contract.client)

        path = self.get_path()

        response = self.client.get(path, HTTP_AUTHORIZATION=self.auth)
        self.assertEqual(response.status_code,
                         status.HTTP_200_OK,
                         msg=response.data)
        self.assertEqual(len(response.data.get("results")),
                         3,
                         msg=response.data)