<commit_before>from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from planner.models import DayTemplateRule, RuleSet, RuleSetElement, DateRule, \
    Schedule, Task
from datetime import datetime, date
import testing.postgresql

Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)

def tearDownModule():
    Postgresql.clear_cache()

class PgTestCase(APITestCase):
    def setUp(self):
        self.postgresql = Postgresql()

    def tearDown(self):
        self.postgresql.stop()


class SimpleRuleTests(PgTestCase):
    def test_create_simplerule(self):
        url = '/planner/simplerules/'
        data = {"name_fr": "<NAME>", "name_en": "Easter Monday","freq": "YEARLY", "byeaster": "1"}
        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(DayTemplateRule.objects.count(),1)
        self.assertEqual(DayTemplateRule.objects.get().name_fr,'Lundi de Pâques')


class RuleSetTests(PgTestCase):
    def test_create_ruleset(self):
        url = '/planner/rulesets/'
        data = {"name_fr" : "Jours fériés France", "name_en" : "Days off France"}
        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(RuleSet.objects.count(),1)
        self.assertEqual(RuleSet.objects.get().name,'Jours fériés France')

class RuleSetElementTests(PgTestCase):
    def test_create_rulesetelement(self):
        url = '/planner/simplerules/'
        data = {"name_fr": "<NAME>", "name_en": "Easter Monday","freq": "YEARLY", "byeaster": "1"}
        response = self.client.post(url, data, format='json')
<commit_msg>change from django-polymorphic to InheritanceManager brought by django-model-utils<commit_after>from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from planner.models import DayTemplateRule, RuleSet, RuleSetElement, DateRule, \
    Schedule, Task
from datetime import datetime, date
import testing.postgresql

Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)

def tearDownModule():
    Postgresql.clear_cache()

class PgTestCase(APITestCase):
    def setUp(self):
        self.postgresql = Postgresql()

    def tearDown(self):
        self.postgresql.stop()


class SimpleRuleTests(PgTestCase):
    def test_create_simplerule(self):
        url = '/planner/daytemplaterules/'
        data = {"name_fr": "L<NAME>", "name_en": "Easter Monday","freq": "YEARLY", "byeaster": "1"}
        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(DayTemplateRule.objects.count(),1)
        self.assertEqual(DayTemplateRule.objects.get().name_fr,'Lundi de Pâques')


class RuleSetTests(PgTestCase):
    def test_create_ruleset(self):
        url = '/planner/rulesets/'
        data = {"name_fr" : "Jours fériés France", "name_en" : "Days off France"}
        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(RuleSet.objects.count(),1)
        self.assertEqual(RuleSet.objects.get().name,'Jours fériés France')

class RuleSetElementTests(PgTestCase):
    def test_create_rulesetelement(self):
        url = '/planner/daytemplaterules/'
        data = {"name_fr": "<NAME>", "name_en": "Easter Monday","freq": "YEARLY", "byeaster": "1"}
        response = self.client.post(url, data, format='json')

{'fraction_non_alphanumeric': 0.12575013638843427, 'fraction_numerical': 0.005455537370430988, 'mean_word_length': 4.246065808297568, 'pattern_counts': {'":': 16, '<': 7, '<?xml version=': 0, '>': 7, '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': '774494', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1128, 'n_words': 229}