def test_getContextData_contextDataReceivedWithCollectionDetail(self, mock_get): colResponse = FakeResponse('mycoldetail') mock_get.return_value = colResponse collectionDetailView = views.CollectionDetailView() collectionDetailView.request = FakeRequest() collectionDetailView.kwargs = {'extra': 'extra'} kwargs = {'object': MyDict('Jon')} context = collectionDetailView.get_context_data(**kwargs) self.assertEquals(context['collection'], colResponse.json()) self.assertEquals(context['selected_tab'], 'Details')
def test_getCollectionContext_500ErrorReceived_raised404Exception(self, mock_get): coll_id = "my_coll_id" kwargs = {'collection_id': coll_id, 'org': None} self.get_response.status_code = 500 mock_get.return_value = self.get_response collectionDetailView = views.CollectionDetailView() collectionDetailView.request = FakeRequest() collectionDetailView.kwargs = {} try: collectionDetailView.get_context_data(**kwargs) self.fail("this should never be called") except HTTPError: self.assertTrue(mock_get.called) pass