When I try to run this test:
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.test import Client
class StatisticTest(TestCase):
def setUp(self):
self.client = Client()
def test_schedule_view(self):
url = reverse('schedule')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'schedule.html')
I get AssertionError: No templates used to render the response.
It's my view:
class Schedule(View):
def get(self, request):
games = add_team_info(query.get_current_schedule())
if games is not []:
available_schedules = generate_schedule_list(games[0]["season_type"], games[0]["week"])
is_available = True
else:
available_schedules = []
is_available = False
return render_to_response("schedule.html",
{"games": games, "available_schedules": available_schedules, "is_available": is_available})
and urls.py:
url(r'^schedule/$', views.Schedule.as_view(), name='schedule'),
Your problem is that assertTemplateUsed
only works with Django templates, not with Jinja templates.
There's an open ticket 24622 about this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With