Ejemplo n.º 1
0
    def transaction__str(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction

        text = "This test checks transaction.str \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test transaction__str in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #

        print("Creating a transaction")
        transaction = Transaction()
        print("Assigning values")
        transaction.this_transaction("type", "asset", "test_household", "test_firm", 1,  2,  3, 4)
        print("Adding the transaction to the books")
        transaction.add_transaction(environment)
        print("Printing transaction:")
        print(transaction.__str__())
Ejemplo n.º 2
0
    sec_qs = {
        row.security_question_1: row.security_answer_1,
        row.security_question_2: row.security_answer_2,
        row.security_question_3: row.security_answer_3

    }
    dt = datetime.combine(pd.Timestamp(row.dob).date(), datetime.min.time())

    bank.add_user(User(row.username, row.password,
                       row['name'], dt, row.address, sec_qs))

# You can assume that the code above is correct.
# Use the space below to test out any functions or pieces of code.

user = User("Huang", "123456", "Zean", datetime.now(), "Qingdao", {
            "favoriteFood": "Apple", "Parent": "Mother", "Sports": "Basketball"})
print(user.__str__())

if type(bank) == Bank:
    print("You can delete this block of code in main.py if you want!")

account = Account(user, AccountType.SAVINGS, "123456", 1000.2)
print(account.__str__())

transaction = Transaction(user._uuid, account._uuid,
                          "123456", datetime.now(), 600, TransactionType.DEPOSIT)
print(transaction.__str__())

print(account.validate_transaction(transaction))
print(account.get_deposit_history())