<commit_before>from wizard_builder.models import QuestionPage

from django.contrib.sites.models import Site
from django.test import TestCase
from django.conf import settings


class TempSiteID():
    '''
        with TempSiteID(1):
            ...
    '''
    def __init__(self, site_id):
        self.site_id_temp = site_id

    def __enter__(self):
        self.site_id_stable = getattr(settings, 'SITE_ID', 1)
        settings.SITE_ID = self.site_id_temp

    def __exit__(self, *args):
        settings.SITE_ID = self.site_id_stable


class SitePageTest(TestCase):

    def test_created_question_page_comes_with_a_site(self):
        page = QuestionPage.objects.create()
        self.assertEqual(page.site.domain, 'example.com')

    def test_on_site_increments_for_default_site(self):
        count_before = QuestionPage.objects.on_site().count()
        QuestionPage.objects.create()
        count_after = QuestionPage.objects.on_site().count()
        self.assertEqual(count_before + 1, count_after)

    def test_on_site_does_not_increment_for_alternate_site(self):
        count_before = QuestionPage.objects.on_site().count()
        page = QuestionPage.objects.create()
        page.site = Site.objects.create()
        page.save()
        count_after = QuestionPage.objects.on_site().count()
        self.assertEqual(count_before, count_after)

    def test_question_page_responds_to_site_id_changes(self):
        site_1_pages = 3<commit_msg>remove redundant tests<commit_after>from wizard_builder.models import QuestionPage

from django.contrib.sites.models import Site
from django.test import TestCase
from django.conf import settings


class TempSiteID():
    '''
        with TempSiteID(1):
            ...
    '''
    def __init__(self, site_id):
        self.site_id_temp = site_id

    def __enter__(self):
        self.site_id_stable = getattr(settings, 'SITE_ID', 1)
        settings.SITE_ID = self.site_id_temp

    def __exit__(self, *args):
        settings.SITE_ID = self.site_id_stable


class SitePageTest(TestCase):

    def test_created_question_page_comes_with_a_site(self):
        page = QuestionPage.objects.create()
        self.assertEqual(page.site.domain, 'example.com')

    def test_question_page_responds_to_site_id_changes(self):
        site_1_pages = 3
{'fraction_non_alphanumeric': 0.09451219512195122, 'fraction_numerical': 0.0039198606271777, 'mean_word_length': 3.3421550094517958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4184927', 'n_tokens_mistral': 724, 'n_tokens_neox': 697, 'n_words': 124}