<commit_before>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)<commit_msg>tests: Add simple TestCase for testing competitions<commit_after>from django.test import TestCase

import problems.models
from models import Competition
from django.contrib.auth.models import Group

from django.db import IntegrityError

class CompetitionCreationTest(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.group = Group(name="TestOrganizers")
        cls.group.save()

    def test_create_simple_competition(self):
        competition = Competition(name="TestCompetition")
        competition.save()

    def test_create_competition_with_organizer_group(self):
        competition = Competition(name="TestCompetition",
                                  organizer_group=self.group)
        competition.save()

    def test_create_duplicate_competitions(self):
        competition1 = Competition(name="DuplicateCompetition")
        competition2 = Competition(name="DuplicateCompetition")

        with self.assertRaises(IntegrityError):
            competition1.save()
            competition2.save()
{'fraction_non_alphanumeric': 0.0801952580195258, 'fraction_numerical': 0.00697350069735007, 'mean_word_length': 3.401840490797546, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '880279', 'n_tokens_mistral': 382, 'n_tokens_neox': 364, 'n_words': 97}