def test_get_context_data_includes_key_camp_dict(self): request = self.factory.get('/fake/') request.user = self.user view = TripDetailView() kwargs = {'pk': self.trip.id} view = setup_view(view, request, **kwargs) view.object = self.trip context = view.get_context_data() self.assertIn('camp_dict', context)
def test_get_context_data_includes_key_page_title(self): ''' The get_context_data includes key 'page_title' ''' request = self.factory.get('/fake/') request.user = self.user view = TripDetailView() kwargs = {'pk': self.trip.id} view = setup_view(view, request, **kwargs) view.object = self.trip context = view.get_context_data() self.assertIn('detail_page_title', context)
def test_get_context_data_returns_end_date_zero_night(self): ''' The get_context_data does not return 'end_date' if the trip has number_nights==0 ''' request = self.factory.get('/fake/') request.user = self.user view = TripDetailView() kwargs = {'pk': self.trip.id} view = setup_view(view, request, **kwargs) view.object = self.trip context = view.get_context_data() self.assertNotIn('end_date', context)
def test_get_context_data_includes_end_date_multi_night(self): ''' The get_context_data includes a key 'end_date' if the trip has number_nights > 0 ''' request = self.factory.get('/fake/') request.user = self.user view = TripDetailView() kwargs = {'pk': self.trip.id} self.trip.number_nights = 1 self.trip.save() view = setup_view(view, request, **kwargs) view.object = self.trip context = view.get_context_data() self.assertIn('end_date', context)