<commit_before># -*- coding: utf-8 -*-
import json
import logging

import mock
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings

from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Build, Version
from readthedocs.projects import tasks
from readthedocs.projects.forms import UpdateProjectForm
from readthedocs.projects.models import Project


log = logging.getLogger(__name__)


class PrivacyTests(TestCase):

    def setUp(self):
        self.eric = User(username='eric')
        self.eric.set_password('<PASSWORD>')
        self.eric.save()

        self.tester = User(username='tester')
        self.tester.set_password('<PASSWORD>')
        self.tester.save()

        tasks.update_docs_task.delay = mock.Mock()

    def _create_kong(
        self, privacy_level='private',
        version_privacy_level='private',
    ):
        self.client.login(username='eric', password='<PASSWORD>')
        log.info(
            'Making kong with privacy: %s and version privacy: %s',
            privacy_level,
            version_privacy_level,
        )
        # Create project via project form, simulate import wizard without magic
        form = UpdateProjectForm(
            data={<commit_msg>Fix tests<commit_after>import logging

import mock
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings

from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Build, Version
from readthedocs.projects.forms import UpdateProjectForm
from readthedocs.projects.models import Project


log = logging.getLogger(__name__)


@mock.patch('readthedocs.projects.tasks.clean_build_task.signature', new=mock.MagicMock)
@mock.patch('readthedocs.projects.tasks.update_docs_task.signature', new=mock.MagicMock)
class PrivacyTests(TestCase):

    def setUp(self):
        self.eric = User(username='eric')
        self.eric.set_password('<PASSWORD>')
        self.eric.save()

        self.tester = User(username='tester')
        self.tester.set_password('<PASSWORD>')
        self.tester.save()

    def _create_kong(
        self, privacy_level='private',
        version_privacy_level='private',
    ):
        self.client.login(username='eric', password='<PASSWORD>')
        log.info(
            'Making kong with privacy: %s and version privacy: %s',
            privacy_level,
            version_privacy_level,
        )
        # Create project via project form, simulate import wizard without magic
        form = UpdateProjectForm(
            data={
{'fraction_non_alphanumeric': 0.09800226159065209, 'fraction_numerical': 0.0003769317753486619, 'mean_word_length': 3.266881028938907, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7048593', 'n_tokens_mistral': 780, 'n_tokens_neox': 743, 'n_words': 173}