Esempio n. 1
0
    def test_checkID(self):
        # I need to remove any prior test configs to fully test!
        tmpFile = 'configuration' + str(11) + '.droveBank'
        File = Path(tmpFile)
        if File.is_file():
            os.remove(tmpFile)

        # Now I can create the new configuration for testing
        myconfig1 = configurationSettings(11)

        # Test to see if an ID exists
        self.assertEqual(myconfig1.checkID('paul'), False)

        # Try to add again and get an error
        myconfig1.createID('paul', 'Password')
        self.assertEqual(myconfig1.checkID('paul'), True)
Esempio n. 2
0
    def test_confirmPassword(self):
        # I need to remove any prior test configs to fully test!
        tmpFile = 'configuration' + str(22) + '.droveBank'
        File = Path(tmpFile)
        if File.is_file():
            os.remove(tmpFile)
        myconfig2 = configurationSettings(22)

        # This will fail since no ID/Password has been created yet
        self.assertEqual(myconfig2.confirmPassword("paul", "Password"), False)

        # add the password into the system
        self.assertEqual(myconfig2.createID("paul", "Password"), True)

        # Now test the password
        self.assertEqual(myconfig2.confirmPassword("paul", "Password"), True)
        self.assertEqual(myconfig2.confirmPassword("paul", "nopass"), False)
        self.assertEqual(myconfig2.confirmPassword("paulk", "Password"), False)
Esempio n. 3
0
    def __init__(self):
        # Get the database name - check if it exists if not, create it
        DBConfig = configurationSettings(1)
        DBFile = DBConfig.getDatabaseName()
        testFile = Path(DBFile)

        # If the file doesn't exist then create the tables
        if testFile.is_file():
            self.db = sqlite3.connect(DBFile)
        else:
            # Once opening the database, the tables must be created
            # - note I used INTEGER's to avoid problems of rounding errors with floating point
            self.db = sqlite3.connect(DBFile)
            self.cursor = db.cursor()
            self.cursor.execute('''
                CREATE TABLE accounts(id INTEGER PRIMARY KEY, name TEXT, balance INTEGER''')
            self.cursor.execute('''
                CREATE TABLE transactions(id INTEGER PRIMARY KEY, datetime TEXT, type TEXT, amount INTEGER''')
            self.cursor.execute('''
                CREATE TABLE nextid(id INTEGER PRIMARY KEY''')
            self.db.commit()
Esempio n. 4
0
    def executeLogin(self):
        accts = configurationSettings(1)

        self.name=self.lent1.get()
        self.password=self.lent2.get()

        # Check if the ID exists - if now ask if you want to create a new one
        if accts.checkID(self.name)==False:
            result = msg.askyesno("Account Not Found", "Do you want to create a new account?")
            if result==True:
                accts.createID(self.name, self.password)
                loginText = "ID " + self.name + " created, login"
                self.updateStatus(loginText)
        else:
            # ID is valid now check if the password matches
            if accts.confirmPassword(self.name, self.password)==False:
                msg.showerror("Error","Incorrect Password")
            else:
                # Update the status label
                self.isLoggedin = True
                loginText = "Logged in as " + self.name
                self.updateStatus(loginText)

        # Load prior accounts - limiting this to 100 accounts for now, however the way it's designed the only limit is memory
        for i in range(1, 100):
            tmpFileName = self.name + str(i)
            tmpFile = Path(tmpFileName)
            if tmpFile.is_file():
                act = account(0)
                act.loadAccounts(tmpFileName, i)
                self.accountList.append(act)
                self.displayAccounts()

        # Remove the login widgets
        self.lent1.grid_forget()
        self.lent2.grid_forget()
        self.lbtn7.grid_forget()
        self.lslbl1.grid_forget()
        self.lslbl2.grid_forget()
        pass
Esempio n. 5
0
 def test_getDatabaseName(self):
     myconfig3 = configurationSettings(33)
     self.assertEqual(myconfig3.getDatabaseName(), "droveBank.db")