Ejemplo n.º 1
0
def test_checking_account_creation(database_setup):
    conn = database_setup
    account_service = AccountService(conn=conn)

    customer = BaseCustomer("1111111111", 11111, "555-555-5555", "*****@*****.**")
    account_service.create_checking_account(customer=customer)

    acct_id, customer_id, _, acct_type, acct_rate = conn.execute(
        "SELECT * FROM accounts"
    ).fetchall()[0]

    assert acct_type == 1
    assert acct_rate == 0.0
Ejemplo n.º 2
0
def test_list_accounts(database_setup):
    conn = database_setup
    customer_service = CustomerService(conn)
    account_service = AccountService(conn)

    customer = customer_service.create_retail_customer(11111, "555-555-5555",
                                                       "*****@*****.**",
                                                       "111-11-1111", "John",
                                                       "Doe")

    customer_id = customer.customer_id

    account_service.create_checking_account(customer)
    account_service.create_checking_account(customer)
    account_service.create_checking_account(customer)

    accounts = customer_service.list_accounts(customer_id)

    assert len(accounts) == 3
Ejemplo n.º 3
0
    def open_checking_account(self, customer_id: Union[str, int],
                              deposit_amount: float) -> CheckingAccount:
        """
        Opens a checking account for the customer associated with the ID passed in

        :param customer_id: ID of customer
        :param deposit_amount: Amount for initial account deposit
        :return: Checking account created
        """
        account_service = AccountService(conn=self.conn)
        ledger_service = LedgerService(conn=self.conn)

        customer = self.get_customer_by_id(customer_id=customer_id)
        acct = account_service.create_checking_account(customer=customer)
        ledger_service.record_entry(account=acct, amount=deposit_amount)

        return acct