Пример #1
0
 def test_no_site_id(self):
     """
     #24488 - The pk should default to 1 if no ``SITE_ID`` is configured.
     """
     del settings.SITE_ID
     create_default_site(self.app_config, verbosity=0)
     self.assertEqual(Site.objects.get().pk, 1)
Пример #2
0
 def test_unavailable_site_model(self):
     """
     #24075 - A Site shouldn't be created if the model isn't available.
     """
     apps = Apps()
     create_default_site(self.app_config, verbosity=0, apps=apps)
     self.assertFalse(Site.objects.exists())
Пример #3
0
 def test_multi_db_with_router(self):
     """
     #16353, #16828 - The default site creation should respect db routing.
     """
     create_default_site(self.app_config, using='default', verbosity=0)
     create_default_site(self.app_config, using='other', verbosity=0)
     self.assertFalse(Site.objects.using('default').exists())
     self.assertTrue(Site.objects.using('other').exists())
Пример #4
0
    def test_save_another(self):
        """
        #17415 - Another site can be created right after the default one.

        On some backends the sequence needs to be reset after saving with an
        explicit ID. There shouldn't be a sequence collisions by saving another
        site. This test is only meaningful with databases that use sequences
        for automatic primary keys such as PostgreSQL and Oracle.
        """
        create_default_site(self.app_config, verbosity=0)
        Site(domain='example2.com', name='example2.com').save()
Пример #5
0
    def test_basic(self):
        """
        #15346, #15573 - create_default_site() creates an example site only if
        none exist.
        """
        with captured_stdout() as stdout:
            create_default_site(self.app_config)
        self.assertEqual(Site.objects.count(), 1)
        self.assertIn("Creating example.com", stdout.getvalue())

        with captured_stdout() as stdout:
            create_default_site(self.app_config)
        self.assertEqual(Site.objects.count(), 1)
        self.assertEqual("", stdout.getvalue())
Пример #6
0
 def test_custom_site_id(self):
     """
     #23945 - The configured ``SITE_ID`` should be respected.
     """
     create_default_site(self.app_config, verbosity=0)
     self.assertEqual(Site.objects.get().pk, 35696)
Пример #7
0
 def test_multi_db(self):
     create_default_site(self.app_config, using='default', verbosity=0)
     create_default_site(self.app_config, using='other', verbosity=0)
     self.assertTrue(Site.objects.using('default').exists())
     self.assertTrue(Site.objects.using('other').exists())