def test_entry_detail_requires_authentication(self): request = utils.get_request( 'get', '/challenges/gigabit/app/', user=utils.get_anon_mock()) response = views.entry_detail(request, 'gigabit', 'app') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/challenges/gigabit/app/'))
def test_entry_is_visible_when_challenge_finishes(self, mock_related): mock_related = mock_related.return_value mock_entry = Mock(spec=Entry)() mock_entry.is_visible_by.return_value = True mock_entry.challenge.has_finished.return_value = True mock_related.get.return_value = mock_entry request = utils.get_request( 'get', '/challenges/gigabit/app/', user=utils.get_user_mock()) response = views.entry_detail(request, 'gigabit', 'app') eq_(response.status_code, 200) eq_(response.template_name, 'challenges/entry_detail.html') mock_entry.challenge.has_finished.assert_called_once()
def test_entry_request_is_successful(self, mock_related): mock_related = mock_related.return_value mock_entry = Mock(spec=Entry)() mock_entry.is_visible_by.return_value = True mock_related.get.return_value = mock_entry request = utils.get_request( 'get', '/challenges/gigabit/app/', user=utils.get_user_mock()) response = views.entry_detail(request, 'gigabit', 'app') eq_(response.status_code, 200) eq_(response.template_name, 'challenges/entry_detail.html') eq_(sorted(response.context_data.keys()), sorted(['challenge', 'application', 'entry', 'answer_list', 'is_owner']) ) mock_entry.is_visible_by.assert_called_once_with(request.user)