<commit_before>from django.urls import reverse
from hypothesis import given, strategies as st, settings
from hypothesis.extra.django import from_model, TestCase

from agir.gestion.tests.strategies import depense, projet, compte
from agir.lib.tests.strategies import person_with_role

admin_user = person_with_role(role__is_superuser=True, role__is_staff=True)

liste_depense_meme_compte = compte().flatmap(
    lambda c: st.lists(depense(compte=c), max_size=5)
)


class BaseAdminTestCase(TestCase):
    def admin_login(self, p):
        self.client.force_login(p.role, backend="agir.people.backend.PersonBackend")


class DepenseAdminTestCase(BaseAdminTestCase):
    @settings(deadline=1000)
    @given(admin_user, liste_depense_meme_compte)
    def test_peut_voir_la_liste(self, p, depenses):
        self.admin_login(p)
        res = self.client.get(
            reverse("admin:gestion_depense_changelist", urlconf="agir.api.admin_urls")
        )

        self.assertEqual(res.status_code, 200)

    @settings(deadline=600)
    @given(admin_user, depense())
    def test_peut_voir_page_changement(self, p, depense):
        self.admin_login(p)

        res = self.client.get(
            reverse("admin:gestion_depense_change", args=(depense.id,))
        )

        self.assertEqual(res.status_code, 200)


class ProjetAdminTestCase(BaseAdminTestCase):
    def admin_login(self, p):
        self.client.force_login(p.role, backend="agir.people.backend.PersonBackend")

    @settings(deadline=700)
    @given(admin_user, st.lists(projet(), max_size=3))
    def test_can_see_changelist(self, p, projets):
        self.admin_login(p)
        res = self.client.get(
            reverse("admin:gestion_projet_changelist", urlconf="agir.api.admin_urls")
        )

        self.assertEqual(res.status_code, 200)

    @settings(deadline=700)
    @given(admin_user, projet())
    def test_peut_voir_page_changement(self, p, projet):
        self.admin_login(p)

        res = self.client.get(reverse("admin:gestion_projet_change", args=(projet.id,)))

        self.assertEqual(res.status_code, 200)<commit_msg>feat: augmenter le timeout d'hypothesis pour voir si ça règle<commit_after>from django.urls import reverse
from hypothesis import given, strategies as st, settings
from hypothesis.extra.django import from_model, TestCase

from agir.gestion.tests.strategies import depense, projet, compte
from agir.lib.tests.strategies import person_with_role

admin_user = person_with_role(role__is_superuser=True, role__is_staff=True)

liste_depense_meme_compte = compte().flatmap(
    lambda c: st.lists(depense(compte=c), max_size=5)
)


class BaseAdminTestCase(TestCase):
    def admin_login(self, p):
        self.client.force_login(p.role, backend="agir.people.backend.PersonBackend")


class DepenseAdminTestCase(BaseAdminTestCase):
    @settings(deadline=1000)
    @given(admin_user, liste_depense_meme_compte)
    def test_peut_voir_la_liste(self, p, depenses):
        self.admin_login(p)
        res = self.client.get(
            reverse("admin:gestion_depense_changelist", urlconf="agir.api.admin_urls")
        )

        self.assertEqual(res.status_code, 200)

    @settings(deadline=1000)
    @given(admin_user, depense())
    def test_peut_voir_page_changement(self, p, depense):
        self.admin_login(p)

        res = self.client.get(
            reverse("admin:gestion_depense_change", args=(depense.id,))
        )

        self.assertEqual(res.status_code, 200)


class ProjetAdminTestCase(BaseAdminTestCase):
    def admin_login(self, p):
        self.client.force_login(p.role, backend="agir.people.backend.PersonBackend")

    @settings(deadline=1000)
    @given(admin_user, st.lists(projet(), max_size=3))
    def test_can_see_changelist(self, p, projets):
        self.admin_login(p)
        res = self.client.get(
            reverse("admin:gestion_projet_changelist", urlconf="agir.api.admin_urls")
        )

        self.assertEqual(res.status_code, 200)

    @settings(deadline=1000)
    @given(admin_user, projet())
    def test_peut_voir_page_changement(self, p, projet):
        self.admin_login(p)

        res = self.client.get(reverse("admin:gestion_projet_change", args=(projet.id,)))

        self.assertEqual(res.status_code, 200)
{'fraction_non_alphanumeric': 0.11207502930832357, 'fraction_numerical': 0.013364595545134817, 'mean_word_length': 4.0545023696682465, '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': '905343', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1424, 'n_words': 224}