Exemplo n.º 1
0
    def test_become_user(self):
        """
        Tests the functionality to be able to become and unbecome another
        user if superuser
        """
        self.setup_request()
        self.request = login_session(self.request, 'test_superuser')

        test_new_superuser = User.objects.create(username="******")
        test_new_superuser.is_superuser = True
        test_new_superuser.save()

        test_new_user = User.objects.create(username='******')
        test_new_user.save()

        become_user(self.request, 'test_new_superuser')
        self.assertEqual(self.request.user.username, 'test_new_superuser')
        become_user(self.request, 'test_new_user')
        self.assertEqual(self.request.user.username, 'test_new_user')

        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_new_superuser')
        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_superuser')
        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_superuser')
Exemplo n.º 2
0
    def test_become_user(self):
        """
        Tests the functionality to be able to become and unbecome another
        user if superuser
        """
        self.setup_request()
        self.request = login_session(self.request, 'test_superuser')

        test_new_superuser = User.objects.create(username="******")
        test_new_superuser.is_superuser = True
        test_new_superuser.save()

        test_new_user = User.objects.create(username='******')
        test_new_user.save()

        become_user(self.request, 'test_new_superuser')
        self.assertEqual(self.request.user.username, 'test_new_superuser')
        become_user(self.request, 'test_new_user')
        self.assertEqual(self.request.user.username, 'test_new_user')

        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_new_superuser')
        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_superuser')
        unbecome_user(self.request)
        self.assertEqual(self.request.user.username, 'test_superuser')
Exemplo n.º 3
0
    def test_become_user(self):
        """
        Tests the functionality to be able to become and unbecome another user if superuser
        """
        self.setup_request()
        request = login_session(self.request, 'development')

        user = User.objects.get_or_create(username='******')[0]
        user.save()

        become_user(self.request, 'development2')
        self.assertTrue(self.request.user.username == 'development2')
        become_user(self.request, 'development')
        self.assertTrue(self.request.user.username == 'development')

        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development2')
        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development')
        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development')
Exemplo n.º 4
0
    def test_become_user(self):
        """
        Tests the functionality to be able to become and unbecome another user if superuser
        """
        self.setup_request()
        request = login_session(self.request, 'development')

        user = User.objects.get_or_create(username='******')[0]
        user.save()

        become_user(self.request, 'development2')
        self.assertTrue(self.request.user.username == 'development2')
        become_user(self.request, 'development')
        self.assertTrue(self.request.user.username == 'development')

        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development2')
        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development')
        unbecome_user(self.request)
        self.assertTrue(self.request.user.username == 'development')