def test_set_current_user_known(self): site = zoom.sites.Site() request = zoom.utils.Bunch( site=site, session=zoom.utils.Bunch(), remote_user='******', profiler=set(), ) set_current_user(request) self.assertEqual(request.user.username, 'user')
def test_set_current_user_unknown(self): zoom.system.site = site = zoom.sites.Site() request = zoom.utils.Bunch( site=site, session=zoom.utils.Bunch(), remote_user='******', profiler=set(), ) # If the user is authenticated but not known to the system # the user should be added to the users table. self.assertFalse(site.users.first(username='******')) set_current_user(request) self.assertEqual(request.user.username, 'newuser') self.assertTrue(site.users.first(username='******')) site.users.delete(username='******') self.assertFalse(site.users.first(username='******'))