Exemplo n.º 1
0
class AddGeneralCommentActionTests(ActionsTestCase):
    """Unit tests for AddGeneralCommentAction."""

    fixtures = ['test_users']

    def setUp(self):
        super(AddGeneralCommentActionTests, self).setUp()

        self.action = AddGeneralCommentAction()

    def test_should_render_with_authenticated(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        request = RequestFactory().request()
        request.user = User.objects.get(username='******')

        self.assertTrue(self.action.should_render({'request': request}))

    def test_should_render_with_anonymous(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        request = RequestFactory().request()
        request.user = AnonymousUser()

        self.assertFalse(self.action.should_render({'request': request}))
Exemplo n.º 2
0
class AddGeneralCommentActionTests(ActionsTestCase):
    """Unit tests for AddGeneralCommentAction."""

    fixtures = ['test_users']

    def setUp(self):
        super(AddGeneralCommentActionTests, self).setUp()

        self.action = AddGeneralCommentAction()

    def test_should_render_with_authenticated(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        request = RequestFactory().request()
        request.user = User.objects.get(username='******')

        self.assertTrue(self.action.should_render({'request': request}))

    def test_should_render_with_anonymous(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        request = RequestFactory().request()
        request.user = AnonymousUser()

        self.assertFalse(self.action.should_render({'request': request}))
Exemplo n.º 3
0
class AddGeneralCommentActionTests(ReadOnlyActionTestsMixin, ActionsTestCase):
    """Unit tests for AddGeneralCommentAction."""

    action = AddGeneralCommentAction()
    fixtures = ['test_users']

    def _create_request_context(self, *args, **kwargs):
        """Create and return objects for use in the request context.

        Args:
            *args (tuple):
                Positional arguments (unused).

            **kwargs (dict):
                Keyword arguments (unused).

        Returns:
            dict:
            Additional context to use when testing read-only actions.
        """
        return {
            'request': self.request,
        }

    def test_should_render_with_authenticated(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        self.request.user = User.objects.get(username='******')
        self.assertTrue(
            self.action.should_render(self._create_request_context()))

    def test_should_render_with_anonymous(self):
        """Testing AddGeneralCommentAction.should_render with authenticated
        user
        """
        self.request.user = AnonymousUser()
        self.assertFalse(
            self.action.should_render(self._create_request_context()))
Exemplo n.º 4
0
    def setUp(self):
        super(AddGeneralCommentActionTests, self).setUp()

        self.action = AddGeneralCommentAction()
Exemplo n.º 5
0
    def setUp(self):
        super(AddGeneralCommentActionTests, self).setUp()

        self.action = AddGeneralCommentAction()