예제 #1
0
    def test_oops_there_is_more_than_one(self):
        Site.objects.create(hostname="example.com", is_default_site=True, root_page=Page.objects.get(pk=2))

        site = Site(hostname="test.com", is_default_site=True, root_page=Page.objects.get(pk=2))
        with self.assertRaises(Site.MultipleObjectsReturned):
            # If there already are multiple default sites, you're in trouble
            site.clean_fields()
예제 #2
0
    def test_oops_there_is_more_than_one(self):
        Site.objects.create(hostname='example.com',
                            is_default_site=True,
                            root_page=Page.objects.get(pk=2))

        site = Site(hostname='test.com',
                    is_default_site=True,
                    root_page=Page.objects.get(pk=2))
        with self.assertRaises(Site.MultipleObjectsReturned):
            # If there already are multiple default sites, you're in trouble
            site.clean_fields()
예제 #3
0
 def test_there_can_only_be_one(self):
     site = Site(hostname='test.com',
                 is_default_site=True,
                 root_page=Page.objects.get(pk=2))
     with self.assertRaises(ValidationError):
         site.clean_fields()
예제 #4
0
 def test_there_can_only_be_one(self):
     site = Site(hostname='test.com', is_default_site=True,
                 root_page=Page.objects.get(pk=2))
     with self.assertRaises(ValidationError):
         site.clean_fields()