<commit_before>from decimal import Decimal
import json

from apps.fund.models import DonationStatuses, Donation, Order
from apps.projects.models import ProjectPlan, ProjectCampaign
from django.test import TestCase, RequestFactory
from django.contrib.contenttypes.models import ContentType
from rest_framework import status
from bluebottle.bluebottle_utils.tests import UserTestsMixin, generate_random_slug
from apps.organizations.tests import OrganizationTestsMixin
from apps.wallposts.models import TextWallPost
from ..models import Project,ProjectPhases, ProjectPitch, ProjectPhaseLog


class ProjectTestsMixin(OrganizationTestsMixin, UserTestsMixin):
    """ Mixin base class for tests using projects. """

    def create_project(self, organization=None, owner=None, title=None, phase='pitch', slug=None, money_asked=0):
        """
        Create a 'default' project with some standard values so it can be
        saved to the database, but allow for overriding.

        The returned object is saved to the database.
        """
        if not owner:
            # Create a new user with a random username
            owner = self.create_user()

        if not slug:
            slug = generate_random_slug()
            while Project.objects.filter(slug=slug).exists():
                slug = generate_random_slug()

        if not title:
            title = generate_random_slug()
            while Project.objects.filter(title=title).exists():
                title = generate_random_slug()
<commit_msg>Removed unused import<commit_after>from decimal import Decimal
import json

from apps.fund.models import DonationStatuses, Donation, Order
from apps.projects.models import ProjectPlan, ProjectCampaign
from django.test import TestCase, RequestFactory
from django.contrib.contenttypes.models import ContentType
from rest_framework import status
from bluebottle.bluebottle_utils.tests import UserTestsMixin, generate_random_slug
from apps.organizations.tests import OrganizationTestsMixin
from apps.wallposts.models import TextWallPost
from ..models import Project,ProjectPhases, ProjectPitch


class ProjectTestsMixin(OrganizationTestsMixin, UserTestsMixin):
    """ Mixin base class for tests using projects. """

    def create_project(self, organization=None, owner=None, title=None, phase='pitch', slug=None, money_asked=0):
        """
        Create a 'default' project with some standard values so it can be
        saved to the database, but allow for overriding.

        The returned object is saved to the database.
        """
        if not owner:
            # Create a new user with a random username
            owner = self.create_user()

        if not slug:
            slug = generate_random_slug()
            while Project.objects.filter(slug=slug).exists():
                slug = generate_random_slug()

        if not title:
            title = generate_random_slug()
            while Project.objects.filter(title=title).exists():
                title = generate_random_slug()

{'fraction_non_alphanumeric': 0.06870229007633588, 'fraction_numerical': 0.0006637902422834385, 'mean_word_length': 3.3554913294797686, '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': '5606857', 'n_tokens_mistral': 770, 'n_tokens_neox': 759, 'n_words': 253}