Esempio n. 1
0
 def saveAccount(self, event):
     if self.validate():
         if self.mode == "new":
             msg = "Account has been added"
             newAccount = Account(self.accountTxt.GetValue())
             newAccount.setAccountUsername(self.usernameTxt.GetValue())
             if not self.user.isAccountExist(newAccount):
                 self.user.addAccount(newAccount, self.passTxt.GetValue())
                 indexItem = 1
                 if self.list_ctrl.GetItemCount() > 0:
                     indexItem = self.list_ctrl.GetItemCount() + 1
                 index = self.list_ctrl.InsertItem(indexItem,
                                                   newAccount.accountName)
                 self.list_ctrl.SetItem(index, 1,
                                        newAccount.accountUsername)
                 self.showDialog(msg, "Information",
                                 wx.OK | wx.ICON_INFORMATION)
             else:
                 msg = "Account is already exist."
                 self.showDialog(msg, "Error", wx.OK | wx.ICON_ERROR)
         else:
             msg = "Account has been updated"
             self.user.addAccount(self.selectedAccount,
                                  self.passTxt.GetValue())
             self.showDialog(msg, "Information",
                             wx.OK | wx.ICON_INFORMATION)
         self.clearEditAccount()
 def setUpClass(self):
     testUtil.setupData()
     #setup test user data
     self.user = User("test_user")
     self.user.changePassword("test_password")
     #setup some accounts
     account = Account("Facebook")
     account.setAccountUsername("user_fb")
     self.user.addAccount(account, "pass_fb")
     account2 = Account("Instagram")
     account2.setAccountUsername("user_instagram")
     self.user.addAccount(account2, "pass_instagram")
Esempio n. 3
0
 def getAccountList(self, force=False):
     if len(self.accountList) > 0 and not force:
         return self.accountList
     else:
         self.accountList.clear()
         accountData = utils.openData(self.username)
         for key in accountData:
             splitKey = key.split("_**_")
             account = Account(splitKey[0])
             account.setAccountUsername(splitKey[1])
             account.setAccountPassword(accountData[key])
             self.accountList.append(account)
         accountData.close()
         return self.accountList
    def test_add_remove_account(self):
        accountName = "Google"
        accountUsername = "******"
        accountPass = "******"        
        account = Account(accountName)
        account.setAccountUsername(accountUsername)
        self.user.addAccount(account, accountPass)

        accountList = self.user.getAccountList()
        self.assertEqual(len(accountList), 3)
        self.assertIn(account, accountList)

        self.assertTrue(self.user.isAccountExist(account))
        
        self.user.removeAccount(account)
        self.assertEqual(len(accountList), 2)
        self.assertNotIn(account, accountList)