コード例 #1
0
    def test_url_override_form_dont_validate_object_already_exists(self):
        self._create_url(site=self.site2, content_object=self.page2)

        form = UrlOverrideForm({
            "internal_name": "Test Name",
            "site": self.site2.pk,
            # self.url is with self.default_site and self.page
            "url": self.url.pk,
            "url_type": self.page_contenttype_id,
            "content_object": self.page2.pk,
        })

        self.assertTrue(form.is_valid())

        instance = form.save()

        self.assertEqual(instance.site_id, self.site2.pk),
        self.assertEqual(instance.content_type_id, self.page_contenttype_id),
        self.assertEqual(instance.object_id, self.page2.pk),
        self.assertEqual(instance.anchor, ""),
        self.assertEqual(instance.manual_url, ""),
        self.assertEqual(instance.relative_path, ""),
        self.assertEqual(instance.mailto, ""),
        self.assertEqual(instance.phone, ""),
        self.assertEqual(instance.url_id, self.url.pk),
コード例 #2
0
    def test_url_override_form(self):
        site3 = Site.objects.create(name="bar.com", domain="bar.com")
        url_version = UrlVersionFactory(
            content__site=self.default_site,
            state=PUBLISHED,
        )
        form = UrlOverrideForm({
            "internal_name": "Test Name",
            "url": url_version.content.pk,
            "site": site3.pk,
            "url_type": "manual_url",
            "manual_url": "http://google.com/",
        })

        self.assertTrue(form.is_valid())
        instance = form.save()

        self.assertEqual(instance.site_id, site3.pk),
        self.assertEqual(instance.manual_url, "http://google.com/"),
        self.assertEqual(instance.relative_path, ""),
        self.assertEqual(instance.content_type_id, None),
        self.assertEqual(instance.object_id, None),
        self.assertEqual(instance.anchor, ""),
        self.assertEqual(instance.mailto, ""),
        self.assertEqual(instance.phone, ""),
        self.assertEqual(instance.url_id, url_version.content.pk),
コード例 #3
0
 def test_url_override_form(self):
     site3 = Site.objects.create(name="bar.com", domain="bar.com")
     form = UrlOverrideForm({
         "url": self.url.pk,
         "site": site3.pk,
         "url_type": "manual_url",
         "manual_url": "http://google.com/",
     })
     self.assertTrue(form.is_valid())
     instance = form.save()
     self.assertEqual(instance.site_id, site3.pk),
     self.assertEqual(instance.manual_url, "http://google.com/"),
     self.assertEqual(instance.relative_path, ""),
     self.assertEqual(instance.content_type_id, None),
     self.assertEqual(instance.object_id, None),
     self.assertEqual(instance.anchor, ""),
     self.assertEqual(instance.mailto, ""),
     self.assertEqual(instance.phone, ""),
     self.assertEqual(instance.url_id, self.url.pk),
コード例 #4
0
 def test_url_override_form(self):
     site3 = Site.objects.create(
         name='bar.com',
         domain='bar.com',
     )
     form = UrlOverrideForm({
         'url': self.url.pk,
         'site': site3.pk,
         'url_type': 'manual_url',
         'manual_url': 'http://google.com/'
     })
     self.assertTrue(form.is_valid())
     instance = form.save()
     self.assertEqual(instance.site_id, site3.pk),
     self.assertEqual(instance.manual_url, 'http://google.com/'),
     self.assertEqual(instance.content_type_id, None),
     self.assertEqual(instance.object_id, None),
     self.assertEqual(instance.anchor, ''),
     self.assertEqual(instance.mailto, ''),
     self.assertEqual(instance.phone, ''),
     self.assertEqual(instance.url_id, self.url.pk),
コード例 #5
0
 def test_url_override_form_dont_validate_object_already_exists(self):
     self._create_url(
         site=self.site2,
         content_object=self.page2,
     )
     form = UrlOverrideForm({
         # self.url is with self.default_site and self.page
         'url': self.url.pk,
         'site': self.site2.id,
         'url_type': self.page_contenttype_id,
         'content_object': self.page2.pk,
     })
     self.assertTrue(form.is_valid())
     instance = form.save()
     self.assertEqual(instance.site_id, self.site2.pk),
     self.assertEqual(instance.content_type_id, self.page_contenttype_id),
     self.assertEqual(instance.object_id, self.page2.pk),
     self.assertEqual(instance.anchor, ''),
     self.assertEqual(instance.manual_url, ''),
     self.assertEqual(instance.mailto, ''),
     self.assertEqual(instance.phone, ''),
     self.assertEqual(instance.url_id, self.url.pk),