<commit_before>from django.test import TestCase

from core.models import DEFAULT_COACH_PHOTO, Coach, Event


class TestEventModel(TestCase):
    fixtures = ['core_views_testdata.json']

    def test_delete(self):
        self.assertTrue(Event.objects.all(), 4)
        event = Event.objects.get(pk=1)
        event.delete()
        self.assertTrue(Event.objects.all(), 3)
        event = Event.all_objects.get(pk=1)
        self.assertTrue(event.is_deleted)

    def test_has_stats(self):
        event = Event()
        self.assertFalse(event.has_stats)

        event = Event(applicants_count=10)
        self.assertFalse(event.has_stats)

        event = Event(attendees_count=20)
        self.assertFalse(event.has_stats)

        event = Event(attendees_count=20, applicants_count=40)
        self.assertTrue(event.has_stats)


class TestCoachModel(TestCase):
    def test_delete(self):
        self.assertEquals(Coach.objects.count(), 0)
        coach = Coach.objects.create(name="<NAME>", twitter_handle="@test")
        self.assertEquals(Coach.objects.count(), 1)
        self.assertEqual(coach.photo_url, DEFAULT_COACH_PHOTO)<commit_msg>Add tests of new Event methods.<commit_after>from django.test import TestCase

from core.models import DEFAULT_COACH_PHOTO, Coach, Event, User


class TestEventModel(TestCase):
    fixtures = ['core_views_testdata.json']

    def test_delete(self):
        self.assertTrue(Event.objects.all(), 4)
        event = Event.objects.get(pk=1)
        event.delete()
        self.assertTrue(Event.objects.all(), 3)
        event = Event.all_objects.get(pk=1)
        self.assertTrue(event.is_deleted)

    def test_has_stats(self):
        event = Event()
        self.assertFalse(event.has_stats)

        event = Event(applicants_count=10)
        self.assertFalse(event.has_stats)

        event = Event(attendees_count=20)
        self.assertFalse(event.has_stats)

        event = Event(attendees_count=20, applicants_count=40)
        self.assertTrue(event.has_stats)

    def test_add_default_content(self):
        event = Event.objects.get(pk=1)
        event.content.all().delete()
        self.assertEquals(event.content.count(), 0)
        event.add_default_content()
        self.assertEquals(event.content.count(), 7)

    def test_add_default_menu(self):
        event = Event.objects.get(pk=1)
        event.menu.all().delete()
        self.assertEquals(event.menu.count(), 0)
        event.add_default_menu()
        self.assertEquals(event.menu.count(), 5)

    def test_invite_organizer_to_team(self):
        event = Event.objects.get(pk=1)
        self.assertEquals(event.team.count(), 2)
        user = User.objects.create(
            first_name="Alice",
            last_name="Smith",
            is_staff=True,
            is_active=True
        )
        event.invite_organizer_to_team(user, is_new_user=True, password="<PASSWORD>")
        self.assertEquals(event.team.count(), 3)


class TestCoachModel(TestCase):
    def test_delete(self):
        self.assertEquals(Coach.objects.count(), 0)
        coach = Coach.objects.create(name="<NAME>", twitter_handle="@test")
        self.assertEquals(Coach.objects.count(), 1)
        self.assertEqual(coach.photo_url, DEFAULT_COACH_PHOTO)
{'fraction_non_alphanumeric': 0.11938461538461538, 'fraction_numerical': 0.011384615384615385, 'mean_word_length': 3.033498759305211, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '4706674', 'n_tokens_mistral': 1040, 'n_tokens_neox': 999, 'n_words': 150}