def test_save_accounts_to_file(self): aa = AccountManager() aa.reset_config() self.assertEqual(len(aa.get_accounts()), 1) url = 'http://cheeky.com' username = '******' password = '******' new_account = Account(url, username, password) aa.add_new_account(new_account) self.assertEqual(len(aa.get_accounts()), 2) bb = AccountManager() aa_account = aa.get_accounts()[0] bb_account = bb.get_accounts()[0] self.assertEquals(aa_account, bb_account)
def test_retrieving_account_with_None_password(self): aa = AccountManager() aa.reset_config() url = 'aa.com' username = '******' password = None new_account = Account(url, username, password) aa.add_new_account(new_account) aa_retrieved = aa.get_account_by_id(1) self.assertEqual(aa_retrieved.get_url(), 'aa.com') self.assertEqual(aa_retrieved.get_password(), None) bb = AccountManager() # new instance, pulled from config file bb_retrieved = bb.get_account_by_id(1) self.assertEqual(bb_retrieved.get_url(), 'aa.com') self.assertEqual(bb_retrieved.get_password(), None)
def main(): #Configure logging options logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) logging.info("Starting server") #Create config object config = Configuration("/home/orikeidar01/config.json", "anylink") config.database.set_default_table("anylink") #Initiate SFTP server AnylinkServer.allow_reuse_address = True server = AnylinkServer(config.bind_addr, config=config) logging.info("Server is now serving") try: #Start SFTP server thread sftp_thread = threading.Thread(target=server.serve_forever) sftp_thread.start() #Create managers requests_manager = RequestsManager(SFTPHandler) account_manager = AccountManager(config.database) requests_manager.start_scanning() #Inject functions setattr(anylink, "get_account_manager", lambda: account_manager) setattr(anylink, "get_requests_manager", lambda: requests_manager) #Start web server anylink.start_website() except KeyboardInterrupt: server.shutdown()
def __init__(self): self.ef = EventFormatter() self.requests_session = None self.account_manager = AccountManager() data = self._parse_user_data() self.init_session(data) self.introduce()
def redirect_login(): username = request.form['username'] password = request.form['password'] account_manager = AccountManager() identity_id = account_manager.signin(username=username, password=password) if identity_id: return redirect(f'/blog?identity_id={identity_id}') else: return redirect('/login')
def test_get_account_by_id(self): aa = AccountManager() aa.reset_config() url = 'hi.com' username = '******' password = None new_account = Account(url, username, password) aa.add_new_account(new_account) self.assertEqual(AccountManager.get_default_account(), aa.get_account_by_id(0)) self.assertEqual(new_account, aa.get_account_by_id(1))
def test_add_new_account_to_config(self): # '__add_new_account_to_config' must throw an exception if it is fed an account # that does not have a section_id url = 'bb.com' username = '******' password = None new_account = Account(url, username, password) aa = AccountManager() self.assertRaises( TypeError, lambda: aa._AccountManager__add_account_to_config(new_account))
def test_add_new_account(self): aa = AccountManager() aa.reset_config() url = 'http://myblog.com' username = '******' password = '******' new_account = Account(url, username, password) aa.add_new_account(new_account) accounts = aa._AccountManager__accounts self.assertEquals(accounts[0], Account(url, username, password)) self.assertEqual(len(accounts), 1)
def sign_in(self, email, password): """ Helper method sign_in(email, password) signs in with the provided email address and password. """ self.email = email self.click_next() self.password = password self.click_sign_in() # should redirect to Account Manager (home, logged in) page account_manager = AccountManager(self.mozwebqa) account_manager.wait_for_page_to_load() return account_manager
def registerNewAccount(self, firstName, lastName, pesel, monthlyDeposit, current=None): password = self.user_manager.add_user(pesel) if monthlyDeposit < 0: raise Bank.RegistrationError( reson='Invalid monthly deposit value. Must be >= 0.') if monthlyDeposit < self.deposit_breakpoint: acc_type = Bank.AccountType.STANDARD acc = AccountManager(pesel, password, firstName, lastName, monthlyDeposit) else: acc_type = Bank.AccountType.PREMIUM acc = PremiumAccountManager( pesel, password, firstName, lastName, monthlyDeposit, self.currency_tracker.get_currencies, self.currency_tracker.get_exchange_ratio) self.adapter.add( acc, self.communicator.stringToIdentity(pesel + str(acc_type))) self.accounts[pesel] = acc base = current.adapter.createProxy( Ice.stringToIdentity(pesel + str(acc_type))) if acc_type == Bank.AccountType.STANDARD: acc_prx = Bank.AccountPrx.uncheckedCast(base) else: acc_prx = Bank.PremiumAccountPrx.uncheckedCast(base) print('Registered ' + str(acc_type) + ' account for pesel ' + pesel) return Bank.RegistrationResponse(password=password, accountType=acc_type, account=acc_prx)
def test_default_account(self): aa = AccountManager() aa.reset_config() expected = AccountManager.get_default_account() self.assertEqual(aa.get_recent_account(), expected)
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- """ Test Bank. """ from account_manager import AccountManager bank = AccountManager() for customer in bank.customers: print(customer.id_, " ", customer.name) for account in bank.accounts: print(account.id_, " ", account.type_, " ", account.balance)
use_itunes = input("Update iTunes? [y/n] ") == "y" if use_itunes: fix_itunes = input( "Compare iTunes and cached versions of playlists to re-sync (fixes problems from program crash, also reverts user modifications)? [y/n] " ) == "y" else: fix_itunes = False make_m3u = input( "Make m3u files (stored in the playlists folder)? [y/n] ") == "y" verify_path_lengths = input( "Rename files too long to copy to Android? [y/n] ") == "y" copy_to_android = input( "Copy music and playlists to Android Music folder? (Won't waste time overwriting, make sure to enable USB debugging) [y/n] " ) == "y" account_manager = AccountManager(logger) account_manager.login_spotify() deezer_object = Deezer() account_manager.login_deezer(deezer_object) music_directory = str(Path.cwd().parents[0] / "music") youtube_tag_dict = collections.OrderedDict() youtube_manager = YoutubeManager(log_manager, logger, account_manager.spotipy, music_directory, youtube_tag_dict) playlist_manager = PlaylistManager(logger=logger, account_manager=account_manager) if get_user_playlists:
if order_qty <= 0: transfer_amt = 0 break succeeded = cash_func(transfer_amt) if succeeded: # TODO: consider adding commission to average price per share stock_func(symbol, order_qty * multiplier, price) else: order_qty -= 1 if order_qty <= 0: transfer_amt = 0 break return { 'shares': order_qty, 'price': price, 'transfer_amt': transfer_amt, 'type': order_type, 'commission': commission_total } # Used for debugging and development if __name__ == '__main__': from account_manager import AccountManager am = AccountManager(100000.) om = OrderManager('data/daily_gold.db', am) pass
def test_initialization(self): a = AccountManager() path = a._AccountManager__configpath self.assertTrue(path.endswith(".lyxblogger/config.cfg"))
def setUp(self): """ creates object for all tests""" Account.account_number = 1 self.bank = AccountManager()
# coding: utf-8 from utils import read_configuration_file from account_manager import AccountManager if __name__ == "__main__": config = read_configuration_file() manager = AccountManager(config['credentials'], config['participant']) manager.run()
START_DAY = '2008_01_02' # Day of initial stock purchases 'YYYY_MM_DD' ex '2016_01_04' '2008_01_02' COMMISSION = .005 # Cost in dollars per share traded COMMISSION_MIN = 1. # Minimum cost in dollars per stock traded COMMISSION_MAX = .005 # Maximum cost in percent of trade value SLIPPAGE = .01 # Average slippage in price due to market volatility #COMMISSION = .0 # Cost in dollars per share traded #COMMISSION_MIN = .0 # Minimum cost in dollars per stock traded #COMMISSION_MAX = .0 # Maximum cost in percent of trade value #SLIPPAGE = .0 # Average slippage in price due to market volatility # Create QuoteManager object quote_manager = QuoteManager(DB_FILEPATH) # Create AccountManager object my_account = AccountManager(START_BALANCE, MARGIN_PERCENT, quote_manager) # Create OrderManager object order_manager = OrderManager(quote_manager, my_account, slippage=SLIPPAGE, commission_min=COMMISSION_MIN, commission=COMMISSION, commission_max=COMMISSION_MAX) # Create an order_history DataFrame order_history = {} # Load signals data signals = pd.read_csv(SIGNALS_PATH, index_col=0) signal_dates = [date.replace('-', '_') for date in signals.index]
def setUp(self): """ Create object for all tests """ # Arrange copyfile(TestBank.src, TestBank.dst) self.bank = AccountManager(TestBank.dst)
def __init__(self, input_file, display=None): self.__display = display or Display() self.__state = 0 self.__entry = None self.__manager = AccountManager() self.__input_file = input_file