Beispiel #1
0
    def test02_logout(self):
        """test02_logout
        test logout, isLogged, and __str__ methods"""

        user = User(4815162342)
        self.assertEquals(user.isLogged(), True)
        user.name = "Joe"
        user.url = "http://example.org/"
        user.outfit = "naked"
        user.privilege = User.ADMIN
        self.assertEquals(user.isLogged(), True)

        # Test __str__
        self.assertEquals(
            "%s" % user,
            'serial = 4815162342, name = Joe, url = http://example.org/, outfit = naked, privilege = %d'
            % User.ADMIN)

        user.logout()
        self.assertEquals(user.isLogged(), False)
        self.assertEquals(user.serial, 0)
        self.assertEquals(user.name, 'anonymous')
        self.assertEquals(user.url, '')
        self.assertEquals(user.outfit, '')
        self.assertEquals(user.privilege, None)
Beispiel #2
0
    def test02_logout(self):
        """test02_logout
        test logout, isLogged, and __str__ methods"""

        user = User(4815162342)
        self.assertEquals(user.isLogged(), True)
        user.name = "Joe"
        user.url = "http://example.org/"
        user.outfit = "naked"
        user.privilege = User.ADMIN
        self.assertEquals(user.isLogged(), True)

        # Test __str__
        self.assertEquals(
            "%s" % user,
            "serial = 4815162342, name = Joe, url = http://example.org/, outfit = naked, privilege = %d" % User.ADMIN,
        )

        user.logout()
        self.assertEquals(user.isLogged(), False)
        self.assertEquals(user.serial, 0)
        self.assertEquals(user.name, "anonymous")
        self.assertEquals(user.url, "")
        self.assertEquals(user.outfit, "")
        self.assertEquals(user.privilege, None)
Beispiel #3
0
 def test03_hasPrivilege(self):
     """test03_hasPrivilege
     test hasPrivilege method"""
     user = User(4815162342)
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), False)
     user.privilege = User.REGULAR
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), True)
     user.privilege = User.ADMIN
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), True)
     self.assertEquals(user.hasPrivilege(User.REGULAR), True)
     user.logout()
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), False)
Beispiel #4
0
 def test03_hasPrivilege(self):
     """test03_hasPrivilege
     test hasPrivilege method"""
     user = User(4815162342)
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), False)
     user.privilege = User.REGULAR
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), True)
     user.privilege = User.ADMIN
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), True)
     self.assertEquals(user.hasPrivilege(User.REGULAR), True)
     user.logout()
     self.assertEquals(user.hasPrivilege(None), True)
     self.assertEquals(user.hasPrivilege(User.ADMIN), False)
     self.assertEquals(user.hasPrivilege(User.REGULAR), False)