Exemple #1
0
 def setUp(self):
     self.loginTest = LoginManagement()
     self.loginButton = gtk.Button()
     self.userEntry1 = gtk.Entry()
     self.passwordEntry1 = gtk.Entry()
     self.userEntry2 = gtk.Entry()
     self.passwordEntry2 = gtk.Entry()
Exemple #2
0
 def setUp(self):
     self.addUserTest = LoginManagement()
     self.userEntry = gtk.Entry()
     self.passwordEntry = gtk.Entry()
     self.loginButton = gtk.Button()
     self.addUserTest.username_taken = False
     self.addUserTest.make_account = True
Exemple #3
0
 def setUp(self):
     self.statsTest = LoginManagement()
     self.viewStats = gtk.Button()
     self.user1 = gtk.Entry()
     self.user1.set_text("Demo01")
     self.user2 = gtk.Entry()
     self.user2.set_text("Demo02")
     self.user3 = gtk.Entry()
     self.user3.set_text("Demo11")
Exemple #4
0
class LoginUser(unittest.TestCase):

    #Setup LoginManagement(), all user and password entries and the login button (widget)
    def setUp(self):
        self.loginTest = LoginManagement()
        self.loginButton = gtk.Button()
        self.userEntry1 = gtk.Entry()
        self.passwordEntry1 = gtk.Entry()
        self.userEntry2 = gtk.Entry()
        self.passwordEntry2 = gtk.Entry()

    #If the user enters the wrong username (with right password) it wont let the user login
    def testNoUserNoLogin(self):
        self.userEntry1.set_text("Vanessa")
        self.userEntry2.set_text("Saki")
        self.passwordEntry1.set_text("Dem@Us3R01")
        self.passwordEntry2.set_text("Dem@Us3R02")
        self.loginTest.user_one_verified = False
        self.loginTest.user_two_verified = False

        self.loginTest.login_user(self.loginButton,self.userEntry1,self.passwordEntry1, self.userEntry2, 1)
        self.assertTrue(self.loginTest.user_one_verified==False, "We should not let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==False, "We should not let User2 login!")

        self.loginTest.login_user(self.loginButton,self.userEntry2,self.passwordEntry2, self.userEntry1, 2)
        self.assertTrue(self.loginTest.user_one_verified==False, "We should not let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==False, "We should not let User2 login!")

    #If the user enters the wrong password (with right username) it wont let the user login
    def testNoPasswordNoLogin(self):
        self.userEntry1.set_text("Demo01")
        self.userEntry2.set_text("Demo02")
        self.passwordEntry1.set_text("WeAreAwesome4Ever*")
        self.passwordEntry2.set_text("YeahTotally!")
        self.loginTest.user__one_verified = False
        self.loginTest.user2_two_verified = False

        self.loginTest.login_user(self.loginButton,self.userEntry1,self.passwordEntry1, self.userEntry2, 1)
        self.assertTrue(self.loginTest.user_one_verified==False, "We should not let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==False, "We should not let User2 login!")

        self.loginTest.login_user(self.loginButton,self.userEntry2,self.passwordEntry2, self.userEntry1, 2)
        self.assertTrue(self.loginTest.user_one_verified==False, "We should not let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==False, "We should not let User2 login!")

    #Only User 1 logs in, User 2 should not be logged in
    def testLoginOnlyUser1(self):
        self.userEntry1.set_text("Demo01")
        self.userEntry2.set_text("Demo02")
        self.passwordEntry1.set_text("Dem@Us3R01")
        self.passwordEntry2.set_text("Dem@Us3R02")
        self.loginTest.user_one_verified= False
        self.loginTest.user_two_verified = False

        self.loginTest.login_user(self.loginButton,self.userEntry1,self.passwordEntry1, self.userEntry2, 1)
        self.assertTrue(self.loginTest.user_one_verified==True, "Let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==False, "User2 should not be logged in!")

    #Only User 2 logs in, User 1 should not be logged in
    def testLoginOnlyUser2(self):
        self.userEntry1.set_text("Demo01")
        self.userEntry2.set_text("Demo02")
        self.passwordEntry1.set_text("Dem@Us3R01")
        self.passwordEntry2.set_text("Dem@Us3R02")
        self.loginTest.user_one_verified = False
        self.loginTest.user_two_verified = False

        self.loginTest.login_user(self.loginButton,self.userEntry2,self.passwordEntry2, self.userEntry1, 2)
        self.assertTrue(self.loginTest.user_one_verified==False, "User1 should not be logged in!")
        self.assertTrue(self.loginTest.user_two_verified==True, "Let User2 login!")

    #Loigin a user when after another user (one user is already logged in)
    def testLoginWithAnotherUserLoggedIn(self):
        self.userEntry1.set_text("Demo01")
        self.userEntry2.set_text("Demo02")
        self.passwordEntry1.set_text("Dem@Us3R01")
        self.passwordEntry2.set_text("Dem@Us3R02")
        self.loginTest.user_one_verified = False
        self.loginTest.user_two_verified = True

        self.loginTest.login_user(self.loginButton,self.userEntry1,self.passwordEntry1, self.userEntry2, 1)
        self.assertTrue(self.loginTest.user_one_verified==True, "Let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==True, "Let User2 login!")

        self.loginTest.user_one_verified = True
        self.loginTest.user_two_verified = False

        self.loginTest.login_user(self.loginButton,self.userEntry2,self.passwordEntry2, self.userEntry1, 2)
        self.assertTrue(self.loginTest.user_one_verified==True, "Let User1 login!")
        self.assertTrue(self.loginTest.user_two_verified==True, "Let User2 login!")

    #When an user tries to login but with the same username as the user already logged in
    def testLoginUser1AndUser2(self):
        self.userEntry1.set_text("Demo01")
        self.userEntry2.set_text("Demo02")
        self.passwordEntry1.set_text("Dem@Us3R01")
        self.passwordEntry2.set_text("Dem@Us3R02")
        self.loginTest.user_one_verified = True
        self.loginTest.user_two_verified = False

        self.loginTest.login_user(self.loginButton, self.userEntry1,self.passwordEntry1, self.userEntry1, 2)
        self.assertTrue(self.loginTest.user_one_verified==True, "User1 already logged in!")
        self.assertTrue(self.loginTest.user_two_verified==False, "User2 already logged in as User1!")

        self.loginTest.user_one_verified = False
        self.loginTest.user_two_verified = True

        self.loginTest.login_user(self.loginButton, self.userEntry2,self.passwordEntry2, self.userEntry2, 1)
        self.assertTrue(self.loginTest.user_one_verified==False, "User1 already logged in as User2!")
        self.assertTrue(self.loginTest.user_two_verified==True, "User2 already logged in!")
Exemple #5
0
class AddUser(unittest.TestCase):

    #Setup LoginManagement(), all user and password entries and the Login button (widget)
    def setUp(self):
        self.addUserTest = LoginManagement()
        self.userEntry = gtk.Entry()
        self.passwordEntry = gtk.Entry()
        self.loginButton = gtk.Button()
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

    #Verify if we can add an user successfully
    #(this test will return false after the second try because the user will already exists in the user.csv)
    def testAddUserSuccessful(self):
        self.userEntry.set_text("BarackObama")
        self.passwordEntry.set_text("Password1*")

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken==False, "Username is not taken yet!")
        self.assertTrue(self.addUserTest.make_account==True, "User should be able to make an account")

    #If the username already exists in the user.csv file it will not let the user create an account
    def testUsernameAlreadyExists(self):
        self.userEntry.set_text("Demo01")
        self.passwordEntry.set_text("Dem@Us3R01")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken == True, "Username is already taken")
        self.assertTrue(self.addUserTest.make_account == True, "User should not be able to make an account")

    #If there is a non alphanumerical character in the username it will not let the user create an account
    def testUsernameRestriction(self):
        self.userEntry.set_text("WeAreAwesomeYeah***")
        self.passwordEntry.set_text("Totally!Yeah*")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken==False, "Username is not taken yet")
        self.assertTrue(self.addUserTest.make_account==False, "Username must contain only ASCII characters")

    #If the password is less than 8 characters, it will not let the user create an account
    def testPasswordContains8Char(self):
        self.userEntry.set_text("Vanessa")
        self.passwordEntry.set_text("Jones1!")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken==False, "Username is not taken yet")
        self.assertTrue(self.addUserTest.make_account==False, "Password must be at least eight characters long!")

    #If the password does not contain one Uppercase letter, it will not let the user create an account
    def testPasswordContainsOneUppercase(self):
        self.userEntry.set_text("Vanessa01")
        self.passwordEntry.set_text("vanessajones1!")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken==False, "Username is not taken yet")
        self.assertTrue(self.addUserTest.make_account==False, "Password must contain one uppercase character!")

    #If the password does not contain one non alphanumeric character, it will not let the user create an account
    def testPasswordContainsNonAlphanumeric(self):
        self.userEntry.set_text("Saki01")
        self.passwordEntry.set_text("Saki4Ever")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken == False, "Username is not taken yet")
        self.assertTrue(self.addUserTest.make_account == False, "Password must contain one non alphanumeric character!")

    #If the password does not contain one number, it will not let the user create an account
    def testPasswordContainsOneDigit(self):
        self.userEntry.set_text("Saki02")
        self.passwordEntry.set_text("SakiForever!!")
        self.addUserTest.username_taken = False
        self.addUserTest.make_account = True

        self.addUserTest.add_user(self.loginButton, self.userEntry, self.passwordEntry)
        self.assertTrue(self.addUserTest.username_taken == False, "Username is not taken yet")
        self.assertTrue(self.addUserTest.make_account == False, "Password must contain one number!")
Exemple #6
0
class StatisticsTests(unittest.TestCase):

    #Setup LoginManagement(), all user and password entries and the viewStats button (widget)
    def setUp(self):
        self.statsTest = LoginManagement()
        self.viewStats = gtk.Button()
        self.user1 = gtk.Entry()
        self.user1.set_text("Demo01")
        self.user2 = gtk.Entry()
        self.user2.set_text("Demo02")
        self.user3 = gtk.Entry()
        self.user3.set_text("Demo11")

    #Verify if returns right personal statistics for user whom has already played
    def testVerifyPersonalUserExist(self):
        self.statsTest.personal_stats(self.viewStats,self.user1)
        self.assertTrue(self.statsTest.wins=="8", "wrong message")
        self.assertTrue(self.statsTest.ties=="0", "wrong message")
        self.assertTrue(self.statsTest.losses=="14", "wrong message")
        self.assertTrue(self.statsTest.games=="22", "wrong message")

    #Verify if returns right personal statistics for user whom never played before
    def testVerifyPersonalUserDoesNotExist(self):
        self.statsTest.personal_stats(self.viewStats,self.user3)
        self.assertTrue(self.statsTest.wins=="", "wrong message")
        self.assertTrue(self.statsTest.ties=="", "wrong message")
        self.assertTrue(self.statsTest.losses=="", "wrong message")
        self.assertTrue(self.statsTest.games=="", "wrong message")

    #Verify if returns right head to head stats for users who already player against each other
    def testVerifyHeadUsersAlreadyPlayed(self):
        self.statsTest.view_head(self.viewStats,self.user1,self.user2)
        self.assertTrue(self.statsTest.player_one_wins=="2","wrong")
        self.assertTrue(self.statsTest.player_ties=="0","wrong")
        self.assertTrue(self.statsTest.player_two_wins=="2","wrong")

    #Verify if returns right head-to head stats for users who never played
    def testVerifyHeadUsersNeverPlayed(self):
        self.statsTest.view_head(self.viewStats,self.user1,self.user3)
        self.assertTrue(self.statsTest.player_one_wins=="","wrong")
        self.assertTrue(self.statsTest.player_ties=="","wrong")
        self.assertTrue(self.statsTest.player_two_wins=="","wrong")

    #Verify if the Default TopTen is right
    def testDefaultTopTen(self):
        self.assertTrue(self.statsTest.wins == [], "wrong" )
        self.assertTrue(self.statsTest.user_names == [], "wrong")

    #Verify if the First player on the list is correct
    def testTopTenFirst(self):
        self.statsTest.view_top_ten(self.viewStats)
        self.assertTrue(self.statsTest.wins[5] == 8, "wrong" )
        self.assertTrue(self.statsTest.user_names[5] == ["Demo01", "Demo06"], "wrong")

    #Verify if the player in the random order is correct
    def testTopTenRandom(self):
        self.statsTest.view_top_ten(self.viewStats)
        self.assertTrue(self.statsTest.wins[3] == 5, "wrong" )
        self.assertTrue(self.statsTest.user_names[3] == ["Demo05", "Demo10"], "wrong")

    #Verify if the Last player on the list is correct
    def testTopTenLast(self):
        self.statsTest.view_top_ten(self.viewStats)
        self.assertTrue(self.statsTest.wins[0] == 2, "wrong" )
        self.assertTrue(self.statsTest.user_names[0] == ["Demo07"], "wrong")