def test_withdrawal_print_error_message_if_not_enough_funds_available(capsys): _account = account.Account() _account.deposit(250) _account.withdrawal(275) captured = capsys.readouterr() assert captured.out == ("You can't withdraw more funds than you have " + "available. Your balance is $250. You have " + "requested $275.\n")
def get_accounts(): accounts = [] profile = _addon.getAddonInfo('profile') cookies_path = xbmc.translatePath(profile).decode("utf-8") account_sk = account.Account( 'sk', _addon.getSetting('username_sk'), _addon.getSetting('password_sk'), 'skylink.sk', cookies_path, bool(_addon.getSetting('pin_protected_content_sk'))) account_cz = account.Account( 'cz', _addon.getSetting('username_cz'), _addon.getSetting('password_cz'), 'skylink.cz', cookies_path, bool(_addon.getSetting('pin_protected_content_cz'))) accounts.append(account_sk) accounts.append(account_cz) return accounts
def _createAcc(self, acc_cfg): acc = account.Account(self) acc.cfg = acc_cfg self.accList.append(acc) self.updateAccount(acc) acc.create(acc.cfg) acc.cfgChanged = False self.updateAccount(acc)
def test_withdrawal_print_error_message_if_requested_amount_is_negative( capsys): _account = account.Account() _account.deposit(100) _account.withdrawal(-50) captured = capsys.readouterr() assert captured.out == ("Your withdrawal amount must be a positive " + "number. $-50 is not valid.\n")
def test_withdrawal_print_error_message_if_requested_amount_higher_than_allowed_withdrawal_limit( capsys): _account = account.Account() _account.deposit(500) _account.withdrawal(450) captured = capsys.readouterr() assert captured.out == ("Your withdrawal request has been denied. ATM " + "daily withdrawal limit is $400.00. You have " + "requested $450.\n")
def test_write(self): acc = ac.Account("test") acc.setValue(25) acc.setDescription("This is a test account") accId = acc.saveOnDatabase() ac2 = ac.getFromDatabase(accId) self.assertEqual(str(ac2.getName()) + "-" + str(ac2.getDescription()), "test-This is a test account", "Assert if the creation and deletion on database works")
def summary(request): response = HtmlTemplateResponse('home.mustache') accounts = request.session["accounts"] account_data = [] for a in accounts: info = account.Account(a) account_data.append(info) response.arguments = {'accounts': account_data} return response
def create_dictionary(): """Create dictionary of accounts from a data file that has acct number, name, pin, and current balance separated by colon""" infile = open('accounts.dat', 'r') for line in infile: [number, name, pin, balance] = line.strip().split(':') acct = account.Account(number, name, pin, float(balance)) accounts[number] = acct infile.close()
def test_withdrawal_print__two_error_messages_if_account_balance_is_zero_or_negative( capsys): _account = account.Account() _account.withdrawal(100) captured = capsys.readouterr() assert captured.out == ("You don't have enough funds to complete the " + "transaction. Your balance is $0.\nYou can't " + "withdraw more funds than you have available. " + "Your balance is $0. You have requested $100.\n")
def main(): print("Welcome to the atm.") while True: amount = None selection = Input.get_selection() if selection == "q": break elif selection == "s": account.Account().show_balance() elif selection is not None: amount = Input.get_amount() if amount is None: pass elif selection == "d": account.Account().deposit(amount) else: account.Account().withdrawal(amount)
def setup(): if CONFIG["converter"] == None: CONFIG["converter"] = convert.Converter() if CONFIG["account"] == None: CONFIG["account"] = account.Account() if CONFIG["environment"] == None: CONFIG["environment"] = Environment(loader=FileSystemLoader(\ searchpath="./WebPages"))
def history(ctx, tickers): debug = ctx.obj['debug'] tickers = upper(csv_list_flatten(tickers)) acc = account.Account(tickers) for ticker, stock in acc.portfolio: print(stock) stock.summarize() print(util.debug.measurements())
def starting(): user = account.Account() try: email = input("Input your email: ") with open("accounts.json", "r") as f: checker = json.load(f) checker[email] except KeyError: print("Email does not exist.") time.sleep(1) starting() # If error does not occur. else: tries = 5 # Create while tries < 5: while tries > 0: password = input("Now your password: "******"accounts.json", "r") as f: checker = json.load(f) if checker[email]["password"] != password: tries -= 1 print(f"Wrong password: you have {tries} tries left.") if tries == 0: print("Signing out...") time.sleep(1) os.system('cls' if os.name == 'nt' else 'clear') mainloop() elif checker[email]["password"] == password: while True: choices = input( "Select: (1) Deposit (2) Withdraw (3) Get balance (q) To exit: " ).lower() if choices == "1": deposit = float(input("Input the amount: ")) user.deposits(deposit, email) print( f"Your new balance is ${user.get_balance(email)}") elif choices == "2": withdraw = float(input("Input the amount: ")) user.withdraws(withdraw, email) print( f"Your new balance is ${user.get_balance(email)}") elif choices == "3": print(f"Your balance is ${user.get_balance(email)}") elif choices == "q".lower(): print("Signing out...") time.sleep(0.5) os.system('cls' if os.name == 'nt' else 'clear') mainloop()
def load_subfunds(self, balance): for name, nmbr, children in balance.subfunds(): name = clean(name) nmbr = number.fmt(nmbr) act = account.Account("Fund", name, nmbr) for child in children: child = number.fmt(child) self.account_[child].parent(nmbr) act.children(child) self.account_[nmbr] = act self.number_[name] = nmbr
def add_account(self, bot, update, args): """ add_account {name} """ group_id = update.message.chat_id if len(args) != 1: bot.sendMessage(chat_id=update.message.chat_id, text="Wrong number of arguments") return self.billingdata.groups[group_id].add_account(a.Account(args[0]))
def main(): chiedu = account.Account("chiedu", "chichi", 200000) nicki = account.Account("Nicki", "Nikoli", 20000) james = account.Account("James", "JimmyB", 210) chiedu.deposit(200000) chiedu.withdraw(20) chiedu.deposit(20) chiedu.withdraw(209) print(chiedu) nicki.deposit(2000) nicki.withdraw(105) nicki.deposit(200) nicki.withdraw(20) print(nicki) james.deposit(10) james.withdraw(30) james.deposit(50) if james.withdraw(250): print(james) else: print("insufficient funds")
def init(): global accountList, config, runTimeItems with open(configFileName, encoding='utf-8') as file: configStr = file.read() # remove unASCII char configStr = re.sub(r'[^\u0000-\u007F]', '', configStr) config = yaml.round_trip_load(configStr) runTimeItems = {itemId: {isInStock: False, isSnappingUp: False} for itemId in config['items'].keys()} for _id, _config in config['accounts'].items(): accountDict[_id] = account.Account(_id, _config) accountList = list(accountDict.values())
def add_credential(self): ''' Method to add existing credentials to the app. ''' print(" ") print("-----Add credential here-----") acc_name = input("Account name: ") acc_username = input("Account username: "******"Account password: ") new_account = account.Account(acc_name, acc_username, acc_password) self.credentials_list.append(new_account) print(f'{acc_name} account credentials added.')
def get_stagnatingIssues(account_name, assignee_email, token, include_archived, issueAge, assignee_name): stagnatingIssues_number = 0 a = account.Account(account_name, token, include_archived) todays_date = date.today() html_email_body = '' projs = a.projects() printed_project_name = False something_to_print = False for proj in projs: printed_project_name = False issues = proj.issuesAssignedTo(assignee_email) if issues: for i in issues: if (i.assignee_email == assignee_email) and (i.status != 'Closed') and (get_date(i.updated_at) + timedelta(days=issueAge) < todays_date): something_to_print = True stagnatingIssues_number += 1 printable_subject = i.subject.replace(u"\u25ba", "►").encode('ascii', 'ignore') if printed_project_name == False: html_email_body += '<li>' + proj.name + '</li>\n<ul>\n' printed_project_name = True html_email_body += '<li><a href="' + i.url + '" font="Source Sans Pro">' + printable_subject + '</a> - <small>Last update: ' + str(get_date(i.updated_at)) + '</small></li>\n' if printed_project_name == True: html_email_body += '</ul>\n' html_email_body += '</ul></body>\n</html>' if something_to_print == True: if stagnatingIssues_number == 1: html_email_body = '<h3>There is <font size="6">' + str(stagnatingIssues_number) + '</font> issue that has been stagnating for 90+ days assigned to ' + assignee_name + '.</h3>\n<ul>\n' + html_email_bod else: html_email_body = '<h3>There are <font size="6">' + str(stagnatingIssues_number) + '</font> issues that have been stagnating for 90+ days assigned to ' + assignee_name + '.</h3>\n<ul>\n' + html_email_body else: html_email_body = '<h3>Good job ' + assignee_name + '! there are <font size="6">0</font> stagnating Sifter issues assigned to you.</h3>\n<ul>\n' + html_email_body html_email_body = '<html>\n<p>This is an automatic reminder of forgotten Sifter issues. Some are legitimate bugs and others stop being applicable as we make changes. Keeping Sifter clean helps prioritizing issue fixes.</b></p>\n' + html_email_body return html_email_body, str(stagnatingIssues_number)
def testConfirmPickup(self): requester = account.Account("Tony", "Stark", "987-654-3210", "Iron", "date") jri = self.r.addJoinRequest(requester, 2) jr = self.r.joinRequests[jri] self.assertEqual(self.r.confirmPickup(jri), "Cannot pick up unconfirmed passenger") self.assertEqual(jr.pickup, None) self.r.confirmJoinRequest(jri) self.r.confirmPickup(jri) self.assertEqual(jr.pickup, True) self.assertEqual(requester.rides, 1) self.assertEqual(self.a.drives, 1)
def firstAccount(): nikolei = account.Account("Nikolei", 12345, 150) nikolei.withdraw(50) print(nikolei.showBalance()) if nikolei.withdraw(110): print(nikolei.showBalance()) else: print("Invalid balance") nikolei.deposit(200) print(nikolei.showBalance()) nikolei.deposit(50) print(nikolei.showBalance()) print(nikolei)
def try_register_account(self, givenName, givenPass, userType): '''(LoginFrame, str, str, account_type Enum) -> NoneType Try to write out a new account with the given information. Display a messagebox describing whether writing succeeded. ''' accountOut = account.Account(givenName, givenPass, userType) if accountOut.writeAccountInfo(): messagebox.showinfo("Created new account", "New account registered\nYou may now log in") else: messagebox.showerror("Could not register", "Given username or password is invalid" + " or account of same name already exists")
def secondAccount(): james = account.Account("James", 67890, 100) james.deposit(200) print(james.showBalance()) james.withdraw(20) print(james.showBalance()) if james.withdraw(200): print(james.showBalance()) else: print("Invalid balance") james.deposit(50) print(james.showBalance()) print(james)
def thirdAccount(): chiedu = account.Account("Chiedu", 7410, 50) chiedu.deposit(50) print(chiedu.showBalance()) chiedu.deposit(150) print(chiedu.showBalance()) if chiedu.withdraw(450): chiedu.showBalance() else: print("Invalid balance") chiedu.withdraw(25) print(chiedu.showBalance()) print(chiedu)
class Atm(object): _id = "12345" _account = account.Account() _customer = None _console = console_library.Console() _card = None _pin = None @property def id(self): return self._id @property def balance(self): return self._account.balance def __init__(self): print("Atm initialized") self.display_welcome() def display_welcome(self): # This should be a console.welcome rather than a direct print. print("Welcome to our very expensive bank!") self._card = self._console.get_card() self._pin = self._console.get_pin() self.display_menu() def deposit(self, deposit): self._account.deposit(deposit) def log_in(self, card_id, pin): self._customer = customer.Customer() self._customer.validate(card_id, pin) self._account = account.Account() def withdrawal(self, withdrawal): self._account.withdrawal(withdrawal) def display_menu(self): choice = self._console.display_menu() print(choice) if (choice[0] == "1"): self.deposit(choice[1]) print("Balance:", self.balance) elif (choice[0] == "2"): self.withdrawal(choice[1]) print("Balance:", self.balance) elif (choice[0] == "3"): # self.transfer(self._choice[1]) print("Balance:", self.balance)
def initializeObjects(excelFileName, assets_list_start_column, assets_list_end_column): ''' Returns all objects needed for reallocation program ''' #### Import and parse the Excel file: #### ########################################## EXCEL_FILE_NAME = excelFileName EXCEL_HEADER_ROW_INDEX = 0 # This is the row number that has the names of the asset classes (cash, bonds, stock, etc.) dataframes = excel_import.importExcel( EXCEL_FILE_NAME, EXCEL_HEADER_ROW_INDEX) # Read the Excel file #### Create DataContainers for Sheets #### ###################################################################### ACCOUNTS_SHEET_NAME = "Accounts" currentAccounts = dc.DataContainer( dataframes[ACCOUNTS_SHEET_NAME] ) # Create a DataContainer for the 'accounts' worksheet TAX_SHEET = "Tax_Status" taxSheet = dc.DataContainer( dataframes[TAX_SHEET] ) # Create a DataContainer for the 'Tax_Status' worksheet SPECIAL_RULES_SHEET = "Other_inputs" specialRulesSheet = dc.DataContainer(dataframes[SPECIAL_RULES_SHEET]) DESIRED_ALLOCATION_SHEET_NAME = "Desired_Allocation" desiredAllocation = dc.DataContainer( dataframes[DESIRED_ALLOCATION_SHEET_NAME]) #### Create Account class Objects for currentAccounts Object #### ###################################################################### categoryList = currentAccounts.getHeaderNames( )[assets_list_start_column:assets_list_end_column] accounts = {} for account in currentAccounts.getRowNames(): owner = currentAccounts.getValue(account, 'Owner') institution = currentAccounts.getValue(account, 'Institution') account_type = currentAccounts.getValue(account, 'Account Type') assets = {} for category in categoryList: assets[category] = currentAccounts.getValue(account, category) accounts[account] = ac.Account(owner, institution, account_type, assets) return accounts
def main(): johnny = account.Account("Johnny", 10, 2000) donny = account.Account("Donny", 11, 200) connie = account.Account("Connie", 12, 20) if johnny.withdraw(1999): print(johnny) else: print("Insufficient funds.") if connie.withdraw(21): print("Insufficient funds") else: print(connie) donny.deposit(200) print(donny) johnny.deposit(25000) print(johnny)
def __init__(self, account_code, ttype, value, comment='', acc_name=None): """Create a new TransactionLine :param account: The account code :param ttype: DEBIT(1), or CREDIT(2) :param value: Decimal nonzero number :param comment: Small comment about the line """ # assert ttype in (cfg.DEBIT, cfg.CREDIT) # Only DEBIT or CREDIT # assert value != 0 # Must have a nonzero value self.account = acc.Account(account_code) self.ttype = enums.Decr(ttype) self.value = utl.dec(value) self.comment = comment self.normalize()
def __init__(self, socket, address, lock): threading.Thread.__init__(self) self.game_state = _.STATE_LOGIN self.login_state = _.LOGIN_ACCOUNT1 self.SOCKET = socket self.ADDRESS = address self.input_buffer = "" self.linkdead = False self.linkdead_count = 0 self.command_buf = [] self.lock = lock self.send_buffer = "" self.password_count = 0 self.nervous_count = 0 self.account = account.Account()
def main(): # ask the user for the host and token host = input('Enter your sifterapp url in quotes:') token = input('Enter your sifter access key in quotes:') # host # the complete url to your sifter subdomain # i.e.: "https://mycompany.sifterapp.com" # token # the 32-character hexdex access key from my profile page a = account.Account(host, token) # instantiate and account projects = a.projects() # use projects method to get projects # dprint some of your project info to the screen to test that # sifter-python is working for p in projects: print print p.name # print project name # print issues info issues = p.issues() for i in issues: print i.number, i.status, i.priority, i.subject print print "*** milestones ***" milestones = p.milestones() for m in milestones: print m.name, m.due_date print print "*** categories ***" categories = p.categories() for c in categories: print c.name print print "*** people ***" people = p.people() for u in people: print u.first_name, u.last_name print print "****************************************" return 0