コード例 #1
0
    def test_get_transactions_no_filters(self):
        """get_transactions: check if all account transactions are
        returned when no filter is provided.
        """
        # given
        number_transactions = 2
        account = self.create_account(
            balance=Decimal("20.00"),
            transactions=TransactionFactory.create_batch(number_transactions))

        # when
        query = get_transactions(account.id)

        # then
        self.assertEqual(number_transactions, query.count())
コード例 #2
0
    def test_get_statement(self):
        """get: check if statement is received for a valid account"""
        # given
        number_transactions = 5
        account = self.create_account(
            transactions=TransactionFactory.create_batch(number_transactions)
        )

        # when
        response = self.app.test_client().get(
            f'/accounts/statement/{account.id}',
        )
        response_data = json.loads(response.data)
        # then
        self.assert200(response)
        self.assertEqual(len(response_data['transactions']), len(account.transactions))
        self.assertEqual(response_data['id'], account.id)