@@ -0,0 +1,1846 @@
+from django.test import TestCase, Client%0A%0Afrom molo.core.models import Main, SiteLanguageRelation, Languages%0Afrom molo.core.tests.base import MoloTestCaseMixin%0Afrom molo.core.utils import generate_slug%0A%0Afrom wagtail.wagtailcore.models import Site%0A%0A%0Aclass TestSites(TestCase, MoloTestCaseMixin):%0A%0A    def setUp(self):%0A        self.mk_main()%0A        self.main = Main.objects.all().first()%0A        self.english = SiteLanguageRelation.objects.create(%0A            language_setting=Languages.for_site(self.main.get_site()),%0A            locale='en',%0A            is_active=True)%0A        self.yourmind = self.mk_section(%0A            self.section_index, title='Your mind')%0A%0A    def test_two_sites_point_to_one_root_page(self):%0A        # assert that there is only one site rooted at main%0A        self.assertEquals(self.main.sites_rooted_here.count(), 1)%0A        client_1 = Client()%0A        # add a site that points to the same root page%0A        site_2 = Site.objects.create(%0A            hostname=generate_slug('site2'), port=80, root_page=self.main)%0A        # create a link buetween the current langauges and the new site%0A        Languages.objects.create(%0A            site_id=site_2.pk)%0A        SiteLanguageRelation.objects.create(%0A            language_setting=Languages.for_site(site_2),%0A            locale='en',%0A            is_active=True)%0A        client_2 = Client(HTTP_HOST=site_2.hostname)%0A%0A        # assert that there are now two sites rooted at main%0A        self.assertEquals(self.main.sites_rooted_here.count(), 2)%0A%0A        # assert that the correct hostname is returned for both sites%0A        response = client_1.get('/sections-main-1/your-mind/')%0A        self.assertEquals(response.status_code, 200)%0A        response = client_2.get(%0A            site_2.root_url + '/sections-main-1/your-mind/')%0A        self.assertEquals(response.status_code, 200)%0A

add test