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(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 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 test_default_account(self): aa = AccountManager() aa.reset_config() expected = AccountManager.get_default_account() self.assertEqual(aa.get_recent_account(), expected)