# -*- coding:utf-8 -*- # # Copyright 2023 © AE UTBM # ae@utbm.fr / ae.info@utbm.fr # All contributors are listed in the CONTRIBUTORS file. # # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # # You can find the whole source code at https://github.com/ae-utbm/sith3 # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) # SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # PREVIOUSLY LICENSED UNDER THE MIT LICENSE, # SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old # OR WITHIN THE LOCAL FILE "LICENSE.old" # import pytest from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase from django.urls import reverse from django.utils import html from django.utils.timezone import localtime, now from django.utils.translation import gettext as _ from club.models import Club, Membership from com.models import News, Poster, Sith, Weekmail, WeekmailArticle from core.models import AnonymousUser, RealGroup, User @pytest.fixture() def user_community(): return User.objects.get(username="comunity") @pytest.mark.django_db @pytest.mark.parametrize( "url", [ reverse("com:alert_edit"), reverse("com:info_edit"), ], ) def test_com_page_is_working(client, url, user_community): client.force_login(user_community) response = client.get(url) assert response.status_code == 200 class ComTest(TestCase): @classmethod def setUpTestData(cls): cls.skia = User.objects.get(username="skia") cls.com_group = RealGroup.objects.filter( id=settings.SITH_GROUP_COM_ADMIN_ID ).first() cls.skia.groups.set([cls.com_group]) def setUp(self): self.client.force_login(self.skia) def test_alert_msg(self): self.client.post( reverse("com:alert_edit"), { "alert_msg": """ ### ALERTE! **Caaaataaaapuuuulte!!!!** """ }, ) r = self.client.get(reverse("core:index")) self.assertContains( r, """
Caaaataaaapuuuulte!!!!
""", ) def test_info_msg(self): self.client.post( reverse("com:info_edit"), { "info_msg": """ ### INFO: **Caaaataaaapuuuulte!!!!** """ }, ) r = self.client.get(reverse("core:index")) self.assertContains( r, """