def test_get_the_data_as_json(self): url = reverse('data_json') request = self.factory.get(url) request.instance = self.instance instance_web = DDAHInstanceWeb.objects.get(id=self.instance.id) response = DDAHInstanceWebJSONView.as_view()(request) self.assertEquals(response.status_code, 200) self.assertEquals(response['Content-Type'], 'application/json') self.assertEquals(response.content, instance_web.to_json()) the_data = json.loads(response.content) self.assertTrue(the_data)
from django.conf.urls import patterns, url from ddah_web.views import DDAHInstanceWebView, DDAHInstanceWebJSONView, FlatPageView urlpatterns = patterns( '', url(r'^pages/(?P<url>.*)$', FlatPageView.as_view(), name='flat_page'), url(r'^data.json$', DDAHInstanceWebJSONView.as_view(), name='data_json'), url(r'^$', DDAHInstanceWebView.as_view(), name='instance_home'), )
from django.conf.urls import patterns, url from ddah_web.views import DDAHInstanceWebView, DDAHInstanceWebJSONView, FlatPageView urlpatterns = patterns('', url(r'^pages/(?P<url>.*)$', FlatPageView.as_view(), name='flat_page'), url(r'^data.json$', DDAHInstanceWebJSONView.as_view(), name='data_json'), url(r'^$', DDAHInstanceWebView.as_view(), name='instance_home'), )