def test_should_always_return_first_event_in_database(self): event2 = Event.objects.create( name='foo', description='bar', ) response = AboutView.as_view()(self.request) self.assertIn(self.event, response.context_data().values()) event2.delete()
from django.conf.urls.defaults import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from mittun.views import IndexView, AboutView admin.autodiscover() urlpatterns = patterns( "", url(r"^$", IndexView.as_view()), url(r"^index/?$", IndexView.as_view(), name="index"), url(r"^about/?$", AboutView.as_view(), name="about"), url(r"^admin/", include(admin.site.urls)), url(r"^bootstrap/?$", include("events.urls")), ) urlpatterns += staticfiles_urlpatterns()
def text_context_object_must_have_an_instance_of_event_model(self): response = AboutView.as_view()(self.request) self.assertIsInstance(response.context_data['event'], Event)
def test_context_object_must_be_called_event(self): response = AboutView.as_view()(self.request) self.assertIn('event', response.context_data().keys())
def test_details_view_should_use_about_template(self): response = AboutView.as_view()(self.request) self.assertIn('about.html', response.template_name)
def test_should_request_the_details_view_and_get_an_200_status_code(self): response = AboutView.as_view()(self.request) self.assertEqual(response.status_code, 200)
from django.conf.urls.defaults import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from mittun.views import IndexView, AboutView admin.autodiscover() urlpatterns = patterns( '', url(r'^$', IndexView.as_view()), url(r'^index/?$', IndexView.as_view(), name="index"), url(r'^about/?$', AboutView.as_view(), name="about"), url(r'^admin/', include(admin.site.urls)), url(r'^sponsors/?$', include('mittun.sponsors.urls')), ) urlpatterns += staticfiles_urlpatterns()
def test_context_object_must_be_called_event(self): response = AboutView.as_view()(self.request, slug=self.event.slug) self.assertTrue('event' in response.context_data().keys())
from django.conf.urls.defaults import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from mittun.views import IndexView, AboutView admin.autodiscover() urlpatterns = patterns('', url(r'^$', IndexView.as_view()), url(r'^index/?$', IndexView.as_view(), name="index"), url(r'^about/?$', AboutView.as_view(), name="about"), url(r'^admin/', include(admin.site.urls)), url(r'^sponsors/?$', include('mittun.sponsors.urls')), ) urlpatterns += staticfiles_urlpatterns()