Всем привет.
Проверяю сейчас открытие страниц с динамическим контентом. Пробую мокать модели с данными:
class Dynamic_pages(TestCase):
@patch('faceset.models.Banner')
@patch('faceset.models.Video')
def test_video6(self, MockBanner, MockVideo):
Video = MockVideo()
Banner = MockBanner()
response = self.client.get('/video6')
self.assertTemplateUsed(response, 'faceset/videopage.html')
self.assertTemplateUsed(response, 'faceset/banner.html')
self.assertTemplateUsed(response, 'faceset/menu.html')
self.assertTemplateUsed(response, 'faceset/footer.html')
Получаю в лицо ошибку:
django.core.urlresolvers.NoReverseMatch: Reverse for 'downvideolike' with arguments '(,)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['downvideolike(?P[0-9]+)$']
Можете подсказать, как правильно мокать в данном случае?
C Фактори Боем данная штука проходит:
class BannerFactory(factory.django.DjangoModelFactory):
class Meta:
model = Banner
bancode = 'test_code_for_deploy'
banlink = 'test_link_for_deploy'
banimg = '../imagination/hand/main-section.jpg'
#####
class VideoFactory(factory.django.DjangoModelFactory):
class Meta:
model = Video
seo_description = "Put any tex"
title = "Put any tex"
description = "Put any tex"
video_image = '../imagination/hand/main-section.jpg'
video_link = "http://www.cybersport.ru/"
thumbnumber = 1
# likedone
#####
<code>class Dynamic_pages(TestCase):
def test_video6(self):
Video = VideoFactory.create(id=6)
Banner = BannerFactory.create()
response = self.client.get('/video6')
self.assertTemplateUsed(response, 'faceset/videopage.html')
self.assertTemplateUsed(response, 'faceset/banner.html')
self.assertTemplateUsed(response, 'faceset/menu.html')
self.assertTemplateUsed(response, 'faceset/footer.html')</code>