Beispiel #1
0
 def test_success_initial_content(self):
     author = ProfileFactory().user
     author2 = ProfileFactory().user
     tutorial = PublishedContentFactory(author_list=[author, author2])
     gallery = GalleryFactory()
     image = ImageFactory(gallery=gallery)
     tutorial.image = image
     tutorial.save()
     staff = StaffProfileFactory()
     login_check = self.client.login(username=staff.user.username,
                                     password='******')
     self.assertTrue(login_check)
     response = self.client.get('{}{}'.format(
         reverse('featured-resource-create'),
         '?content_type=published_content&content_id={}'.format(
             tutorial.pk)))
     initial_dict = response.context['form'].initial
     self.assertEqual(initial_dict['title'], tutorial.title)
     self.assertEqual(initial_dict['authors'],
                      '{}, {}'.format(author, author2))
     self.assertEqual(initial_dict['type'], _('Un tutoriel'))
     self.assertEqual(
         initial_dict['url'],
         'http://testserver{}'.format(tutorial.get_absolute_url_online()))
     self.assertEqual(
         initial_dict['image_url'],
         'http://testserver{}'.format(image.physical['featured'].url))
Beispiel #2
0
 def test_success_initial_content(self):
     author = ProfileFactory().user
     author2 = ProfileFactory().user
     tutorial = PublishedContentFactory(author_list=[author, author2])
     gallery = GalleryFactory()
     image = ImageFactory(gallery=gallery)
     tutorial.image = image
     tutorial.save()
     staff = StaffProfileFactory()
     login_check = self.client.login(username=staff.user.username,
                                     password="******")
     self.assertTrue(login_check)
     response = self.client.get("{}{}".format(
         reverse("featured-resource-create"),
         "?content_type=published_content&content_id={}".format(
             tutorial.pk)))
     initial_dict = response.context["form"].initial
     self.assertEqual(initial_dict["title"], tutorial.title)
     self.assertEqual(initial_dict["authors"],
                      "{}, {}".format(author, author2))
     self.assertEqual(initial_dict["type"], _("Un tutoriel"))
     self.assertEqual(
         initial_dict["url"],
         "http://testserver{}".format(tutorial.get_absolute_url_online()))
     self.assertEqual(
         initial_dict["image_url"],
         "http://testserver{}".format(image.physical["featured"].url))
Beispiel #3
0
 def test_success_initial_content(self):
     author = ProfileFactory().user
     author2 = ProfileFactory().user
     tutorial = PublishedContentFactory(author_list=[author, author2])
     gallery = GalleryFactory()
     image = ImageFactory(gallery=gallery)
     tutorial.image = image
     tutorial.save()
     staff = StaffProfileFactory()
     login_check = self.client.login(
         username=staff.user.username,
         password='******'
     )
     self.assertTrue(login_check)
     response = self.client.get('{}{}'.format(reverse('featured-resource-create'),
                                              '?content_type=published_content&content_id={}'.format(tutorial.pk)))
     initial_dict = response.context['form'].initial
     self.assertEqual(initial_dict['title'], tutorial.title)
     self.assertEqual(initial_dict['authors'], '{}, {}'.format(author, author2))
     self.assertEqual(initial_dict['type'], _('Un tutoriel'))
     self.assertEqual(initial_dict['url'], 'http://testserver{}'.format(tutorial.get_absolute_url_online()))
     self.assertEqual(initial_dict['image_url'], image.physical.url)