Exemple #1
0
class HomeViewTests(TestCase):
    def setUp(self):
        self.view = HomeView()
        self.view.request = Mock()

    def test_get_authenticated_redirect(self):
        """
        If the current user is authenticated, redirect them to the
        profile detail view.
        """
        self.view.request.user.is_authenticated.return_value = True

        with patch('oneanddone.base.views.redirect') as redirect:
            eq_(self.view.get(), redirect.return_value)
            redirect.assert_called_with('users.profile.detail')

    def test_get_unauthenticated_super(self):
        """
        If the current user isn't authenticated, call the parent method.
        """
        self.view.request.user.is_authenticated.return_value = False

        with patch('oneanddone.base.views.HomeView.get') as parent_get:
            eq_(self.view.get('baz', foo='bar'), parent_get.return_value)
            parent_get.assert_called_with('baz', foo='bar')
Exemple #2
0
class HomeViewTests(TestCase):
    def setUp(self):
        self.view = HomeView()
        self.view.request = Mock()

    def test_get_unauthenticated_super(self):
        """
        If the current user isn't authenticated, call the parent method.
        """
        self.view.request.user.is_authenticated.return_value = False

        with patch('oneanddone.base.views.HomeView.get') as parent_get:
            eq_(self.view.get('baz', foo='bar'), parent_get.return_value)
            parent_get.assert_called_with('baz', foo='bar')

    def test_dispatch_authenticated_without_profile(self):
        """
        If the user is authenticated but doesn't have a profile,
        redirect them to the create profile page.
        """
        request = Mock()
        request.user = UserFactory.create()
        request.user.is_authenticated = Mock(return_value=True)

        with patch('oneanddone.base.views.redirect') as redirect:
            eq_(self.view.dispatch(request), redirect.return_value)
            redirect.assert_called_with('users.profile.create')
class HomeViewTests(TestCase):
    def setUp(self):
        self.view = HomeView()
        self.view.request = Mock()

    def test_dispatch_authenticated_without_profile(self):
        """
        If the user is authenticated but doesn't have a profile,
        redirect them to the create profile page.
        """
        request = Mock()
        request.user = UserFactory.create()
        request.user.is_authenticated = Mock(return_value=True)

        with patch('oneanddone.base.views.redirect') as redirect:
            eq_(self.view.dispatch(request), redirect.return_value)
            redirect.assert_called_with('users.profile.create')

    def test_get_context_data_returns_added_values(self):
        """
        The task_list_heading and teams values
        should be included in the context data.
        """
        with patch('oneanddone.base.views.FilterView.get_context_data'
                   ) as get_context_data:
            get_context_data.return_value = {}
            ctx = self.view.get_context_data()
            eq_(ctx['task_list_heading'], _('Suggested First Tasks'))
            ok_(isinstance(ctx['teams'], QuerySet))

    def test_get_unauthenticated_super(self):
        """
        If the current user isn't authenticated, call the parent method.
        """
        self.view.request.user.is_authenticated.return_value = False

        with patch('oneanddone.base.views.HomeView.get') as parent_get:
            eq_(self.view.get('baz', foo='bar'), parent_get.return_value)
            parent_get.assert_called_with('baz', foo='bar')
Exemple #4
0
class HomeViewTests(TestCase):
    def setUp(self):
        self.view = HomeView()
        self.view.request = Mock()

    def test_dispatch_authenticated_without_profile(self):
        """
        If the user is authenticated but doesn't have a profile,
        redirect them to the create profile page.
        """
        request = Mock()
        request.user = UserFactory.create()
        request.user.is_authenticated = Mock(return_value=True)

        with patch('oneanddone.base.views.redirect') as redirect:
            eq_(self.view.dispatch(request), redirect.return_value)
            redirect.assert_called_with('users.profile.create')

    def test_get_context_data_returns_added_values(self):
        """
        The task_list_heading and teams values
        should be included in the context data.
        """
        with patch('oneanddone.base.views.FilterView.get_context_data') as get_context_data:
            get_context_data.return_value = {}
            ctx = self.view.get_context_data()
            eq_(ctx['task_list_heading'], _('Suggested First Tasks'))
            ok_(isinstance(ctx['teams'], QuerySet))

    def test_get_unauthenticated_super(self):
        """
        If the current user isn't authenticated, call the parent method.
        """
        self.view.request.user.is_authenticated.return_value = False

        with patch('oneanddone.base.views.HomeView.get') as parent_get:
            eq_(self.view.get('baz', foo='bar'), parent_get.return_value)
            parent_get.assert_called_with('baz', foo='bar')
Exemple #5
0
 def setUp(self):
     self.view = HomeView()
     self.view.request = Mock()
Exemple #6
0
 def setUp(self):
     self.view = HomeView()
     self.view.request = Mock()