Esempio n. 1
0
 def test_save_and_load_file(self):
     
     ui_before = UserInfo("lmurphey", "Luke Murphey", ["admin", "power"])
     ui_before.updateLastLogin()
     ui_before.updateLoadSignature()
     
     self.assertTrue(ui_before.save(self.tmp_dir ), "File was not saved properly" )
     
     ui_after = UserInfo.loadFile(os.path.join(self.tmp_dir, "3f0d712f3d3d99e26aa3a45a1f37494c.json") )
     
     self.assertEqual(ui_after.realname, ui_before.realname)
     self.assertEqual(ui_after.username, ui_before.username)
     self.assertEqual(ui_after.roles, ui_before.roles)
     self.assertEqual(ui_after.lastLoginTime, ui_before.lastLoginTime)
     self.assertEqual(ui_after.load_signature, ui_before.load_signature)
Esempio n. 2
0
    def test_signature_change_with_login_time(self):
        
        ui = UserInfo("jdoe", "John Doe", ["admin", "power"])
        
        self.assertFalse(ui.hasChanged())
        
        ui.updateLastLogin()

        self.assertTrue(ui.hasChanged())
        ui.updateLoadSignature()
        self.assertFalse(ui.hasChanged())

        # Let the time change a bit by sleeping a bit
        time.sleep(2)
        ui.updateLastLogin()
        self.assertTrue(ui.hasChanged())