def setUp(self): self.test_caccount = Account(_balance=270, account_type='checking', account_num=4235, name='Bill') self.test_saccount = Account(_balance=10454, account_type='savings', account_num=4235, name='Bill')
def post(self): user = users.get_current_user() account = Account.get_by_user(user) action = self.request.get("action") if action == "approve": source = Account.get_by_hash(self.request.get("source")) channel = Channel.get_by_source_and_target(source, account) channel.status = "enabled" channel.put() if action == "disable": source = Account.get_by_hash(self.request.get("source")) channel = Channel.get_by_source_and_target(source, account) channel.status = "disabled" self.redirect("/dashboard/sources")
def isEditor(user): if user: account = Account.query(Account.username == user.nickname()).get() if account: if account.power == 'editor': return True return False
def setUp(self): # Clients self.c_1 = Client("Ana", "Silva", "555.042.695-95") self.c_2 = Client("Pedro", "Ramos", "024.542.358-20") # "Normal" accounts self.a_1 = Account("1476-6", self.c_1, "5000") self.a_2 = Account("1356-7", self.c_2, "6000") # Saving accounts self.sa_1 = SavingAccount("3574-6", self.c_1, "2000") self.sa_2 = SavingAccount("4751-3", self.c_2, "3000") # Checking accounts self.ca_1 = CheckingAccount("3687-1", self.c_1, "4000") self.ca_2 = CheckingAccount("1473-5", self.c_2, "1000")
def test_basic(): bond = InvestmentClass('Bond') equity = InvestmentClass('Equity') cash = InvestmentClass('Cash') xsb = ComponentType("XSB", bond) xic = ComponentType("XIC", equity) cash_dollars = ComponentType("Cash Dollars", cash) rrsp = Account('john RRSP') rrsp_xsb = Component(rrsp, xsb, 10000) rrsp_xic = Component(rrsp, xic, 10000) rrsp_cash = Component(rrsp, cash_dollars, 0) bond_allocation = Allocation(bond, 0.4) equity_allocation = Allocation(equity, 0.6) cash_allocation = Allocation(cash, 0.0) allocations = [bond_allocation, equity_allocation, cash_allocation] portfolio = Portfolio([rrsp_xsb, rrsp_xic, rrsp_cash]) component_allocations = portfolio.get_allocations(allocations) assert component_allocations[rrsp_xsb] == 0.4 assert component_allocations[rrsp_xic] == 0.6 assert component_allocations[rrsp_cash] == 0.0
def get(self): user = users.get_current_user() logout_url = users.create_logout_url("/") account = Account.get_by_user(user) pending_channels = Channel.get_all_by_target(account).filter("status =", "pending") enabled_channels = Channel.get_all_by_target(account).filter("status =", "enabled") self.response.out.write(template.render("templates/dashboard_sources.html", locals()))
def get(self): user = users.get_current_user() logout_url = users.create_logout_url("/") account = Account.all().filter("user ="******"status =", "pending") self.response.out.write(template.render("templates/dashboard_settings.html", locals()))
def get(self): user = users.get_current_user() logout_url = users.create_logout_url("/") account = Account.all().filter("user ="******"status =", "pending") notifications = Notification.all().filter("target =", account).order("-created").fetch(1000) self.response.out.write(template.render("templates/dashboard_history.html", locals()))
def post(self): user = users.get_current_user() account = Account.all().filter("user ="******"source_enabled", None): account.source_enabled = True account.source_name = self.request.get("source_name", None) account.source_icon = self.request.get("source_icon", None) else: account.source_enabled = False account.put() self.redirect("/dashboard/settings")
def test_get_balance(self): test_account = Account(_balance=500, account_type='checking', account_num=1435, name='Jorge') self.assertEqual(test_account.get_funds(), 500) test_account.withdraw(250) self.assertEqual(test_account.get_funds(), 250)
def get(self): user = users.get_current_user() logout_url = users.create_logout_url("/") account = Account.all().filter("user ="******"/dashboard/history")
def test_basic_spouse(): bond = InvestmentClass('Bond') equity = InvestmentClass('Equity') cash = InvestmentClass('Cash') xsb = ComponentType("XSB", bond) xic = ComponentType("XIC", equity) cash_dollars = ComponentType("Cash Dollars", cash) john_rrsp = Account('john RRSP') sue_rrsp = Account('sue RRSP') john_rrsp_xsb = Component(john_rrsp, xsb, 10000) john_rrsp_xic = Component(john_rrsp, xic, 10000) john_rrsp_cash = Component(john_rrsp, cash_dollars, 0) sue_rrsp_xsb = Component(sue_rrsp, xsb, 10000) sue_rrsp_xic = Component(sue_rrsp, xic, 10000) sue_rrsp_cash = Component(sue_rrsp, cash_dollars, 0) bond_allocation = Allocation(bond, 0.4) equity_allocation = Allocation(equity, 0.6) cash_allocation = Allocation(cash, 0.0) allocations = [bond_allocation, equity_allocation, cash_allocation] portfolio = Portfolio([ john_rrsp_xsb, john_rrsp_xic, john_rrsp_cash, sue_rrsp_xsb, sue_rrsp_xic, sue_rrsp_cash ]) component_allocations = portfolio.get_allocations(allocations) assert component_allocations[john_rrsp_xsb] == 0.2 assert component_allocations[john_rrsp_xic] == 0.3 assert component_allocations[john_rrsp_cash] == 0.0 assert component_allocations[sue_rrsp_xsb] == 0.2 assert component_allocations[sue_rrsp_xic] == 0.3 assert component_allocations[sue_rrsp_cash] == 0.0
def start_acc(): open = input(""" BANK OF MOOLA has a SPECIAL 1-MINUTE OFFER of a free savings and checking with $1000 deposited into each!!!! Only 20, 19, 18 seconds left... Would you like to open an account? (y or n) """) if open != 'n': clear() # makes space in terminal view account = Account(1000, 1000, 0.001) menu_screen(account) else: clear() chalk.red("You're on the road to ruin. Good luck, chief!")
class TestMain(unittest.TestCase): def setUp(self): # Clients self.c_1 = Client("Ana", "Silva", "555.042.695-95") self.c_2 = Client("Pedro", "Ramos", "024.542.358-20") # "Normal" accounts self.a_1 = Account("1476-6", self.c_1, "5000") self.a_2 = Account("1356-7", self.c_2, "6000") # Saving accounts self.sa_1 = SavingAccount("3574-6", self.c_1, "2000") self.sa_2 = SavingAccount("4751-3", self.c_2, "3000") # Checking accounts self.ca_1 = CheckingAccount("3687-1", self.c_1, "4000") self.ca_2 = CheckingAccount("1473-5", self.c_2, "1000") def tearDown(self): pass def test_first(self): self.assertEqual(self.c_1.first, "Ana") self.assertEqual(self.c_2.first, "Pedro") def test_account_number(self): self.assertIsNot(self.a_1._number, "1111-1") self.assertIsNot(self.a_2._number, "2222-2") def test_cpf(self): self.assertIsNot(self.c_1.cpf, "000.000.000-00") self.assertIsNot(self.c_2.cpf, "111.111.111-11") def test_deposit(self): self.a_1.deposit(50) self.a_2.deposit(60) self.assertEqual(self.a_1.bank_statement(), 5050.0) self.assertEqual(self.a_2.bank_statement(), 6060.0) def test_transfer_to(self): self.a_1.transfer_to(self.a_2, 500) self.assertEqual(self.a_1.bank_statement(), 4500.0) self.assertEqual(self.a_2.bank_statement(), 6500.0) def test_saving_account_update(self): self.sa_1.update(0.01) self.sa_2.update(0.02) self.assertEqual(self.sa_1._balance, 2060) self.assertEqual(self.sa_2._balance, 3180) def test_checking_account_update(self): self.ca_1.update(0.01) self.ca_2.update(0.02) self.assertEqual(self.ca_1._balance, 4080) self.assertEqual(self.ca_2._balance, 1040) def test_checking_account_deposit(self): self.ca_1.deposit(150) self.ca_2.deposit(4200) self.assertEqual(self.ca_1._balance, 4149.9) self.assertEqual(self.ca_2._balance, 5199.9)
def RouteProfile(self): """ :rtype: object """ userid = self.request.get('userid') useraction = self.request.get('useraction') if useraction == "save": names = self.request.get('names') cell = self.request.get('cell') email = self.request.get('email') website = self.request.get('website') photourl = self.request.get('photourl') box = self.request.get('box') postalcity = self.request.get('city') postalprovince = self.request.get('province') postalcode = self.request.get('postalcode') stand = self.request.get('stand') street = self.request.get('street') physicalcity = self.request.get('physicalcity') physicalprovince = self.request.get('physicalprovince') physicalcode = self.request.get('physicalcode') account_request = Account.query(Account.userid == userid) this_account_list = account_request.fetch() postal_request = PostalAddress.query( PostalAddress.userid == userid) this_postal_list = postal_request.fetch() physical_request = PhysicalAddress.query( PhysicalAddress.userid == userid) this_physical_list = physical_request.fetch() wallet_request = Wallet.query(Wallet.userid == userid) this_wallet_list = wallet_request.fetch() if len(this_account_list) > 0: this_account = this_account_list[0] if len(this_postal_list) > 0: this_postal = this_postal_list[0] else: this_postal = PostalAddress() this_postal.write_userid(userid=userid) if len(this_physical_list) > 0: this_physical = this_physical_list[0] else: this_physical = PhysicalAddress() this_physical.write_userid(userid=userid) if len(this_wallet_list) > 0: this_wallet = this_wallet_list[0] else: this_wallet = Wallet() this_wallet.write_userid(userid=userid) this_wallet.put() this_account.write_names(names=names) this_account.write_cell(cell=cell) this_account.write_email(email=email) this_account.write_website(website=website) this_account.write_photourl(photourl=photourl) this_account.put() this_postal.write_box(box=box) this_postal.write_city(city=postalcity) this_postal.write_province(province=postalprovince) this_postal.write_postalcode(postalcode=postalcode) this_postal.put() this_physical.write_stand(stand=stand) this_physical.write_streetname(streetname=street) this_physical.write_city(city=physicalcity) this_physical.write_province(province=physicalprovince) this_physical.write_postalcode(postalcode=physicalcode) this_physical.put() self.response.write("successfully updated profile information") else: account_request = Account.query(Account.userid == userid) this_account_list = account_request.fetch() postal_request = PostalAddress.query( PostalAddress.userid == userid) this_postal_list = postal_request.fetch() physical_request = PhysicalAddress.query( PhysicalAddress.userid == userid) this_physical_list = physical_request.fetch() wallet_request = Wallet.query(Wallet.userid == userid) this_wallet_list = wallet_request.fetch() if len(this_account_list) > 0: this_account = this_account_list[0] if len(this_postal_list) > 0: this_postal = this_postal_list[0] else: this_postal = PostalAddress() this_postal.write_userid(userid=userid) this_postal.put() if len(this_physical_list) > 0: this_physical = this_physical_list[0] else: this_physical = PhysicalAddress() this_physical.write_userid(userid=userid) this_physical.put() if len(this_wallet_list) > 0: this_wallet = this_wallet_list[0] else: this_wallet = Wallet() this_wallet.write_userid(userid=userid) this_wallet.put() template = template_env.get_template( 'templates/pages/profile.html') context = { 'this_account': this_account, 'this_postal': this_postal, 'this_physical': this_physical, 'this_wallet': this_wallet } self.response.write(template.render(context)) else: this_account = Account() this_account.write_userid(userid=userid) this_account.put() this_postal = PostalAddress() this_postal.write_userid(userid=userid) this_postal.put() this_physical = PhysicalAddress() this_physical.write_userid(userid=userid) this_physical.put() this_wallet = Wallet() this_wallet.write_userid(userid=userid) this_wallet.put() template = template_env.get_template( 'templates/pages/profile.html') context = { 'this_account': this_account, 'this_postal': this_postal, 'this_physical': this_physical, 'this_wallet': this_wallet } self.response.write(template.render(context))
def post(self): router = self.request.get('route') logging.info(router) if router == "login": template = template_env.get_template('templates/pages/login.html') context = {} self.response.write(template.render(context)) elif router == "new-user": names = self.request.get('names') email = self.request.get('email') password = self.request.get('password') userid = self.request.get('userid') account_request = Account.query(Account.userid == userid) account_list = account_request.fetch() if len(account_list) == 0: account = Account() account.write_names(names=names) account.write_email(email=email) account.write_userid(userid=userid) account.write_password(password=password) account.put() self.response.write('successfully created a new user account') else: self.response.write('you already have an account please login') elif router == "settings": self.SettingsRouter() elif router == "profile": self.RouteProfile() elif router == "drive": userid = self.request.get('userid') drive_request = Drive.query(Drive.userid == userid) this_drive_list = drive_request.fetch() if len(this_drive_list) > 0: this_drive = this_drive_list[0] else: this_drive = Drive() this_drive.write_driveid(driveid=this_drive.create_driveid()) this_drive.put() art_request = ProjectArt.query( ProjectArt.driveid == this_drive.driveid) this_art_files = art_request.fetch() template = template_env.get_template('templates/pages/drive.html') context = { 'this_drive': this_drive, 'this_art_files': this_art_files } self.response.write(template.render(context)) elif router == "addfunds": template = template_env.get_template( 'templates/pages/addfunds.html') context = {} self.response.write(template.render(context)) elif router == "projects": template = template_env.get_template( 'templates/pages/projects.html') context = {} self.response.write(template.render(context)) elif router == "chat": template = template_env.get_template('templates/pages/chat.html') context = {} self.response.write(template.render(context)) elif router == "dashboard": #TODO- note that the admin can login through the dashboard link ... /dashboard if users.is_current_user_admin(): template = template_env.get_template( 'templates/pages/dashboard.html') context = {} self.response.write(template.render(context)) else: template = template_env.get_template( 'templates/pages/500.html') context = {} self.response.write(template.render(context)) elif router == "inbox": template = template_env.get_template('templates/pages/inbox.htm') context = {} self.response.write(template.render(context)) elif router == "logout": template = template_env.get_template('templates/pages/logout.html') context = {} self.response.write(template.render(context))
def test_account_creation_from_csv_string(self): record = '5902692944186857,name,checking,151.5' test_account = Account.from_csv_string(record) self.assertEqual(test_account._balance, 151.50) self.assertEqual(test_account.account_type, 'checking')