# -*- coding:utf-8 -* # # Copyright 2023 © AE UTBM # ae@utbm.fr / ae.info@utbm.fr # # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # # You can find the source code of the website 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" # # from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase from django.conf import settings from django.urls import reverse from django.core.management import call_command 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 Sith, News, Weekmail, WeekmailArticle, Poster from core.models import User, RealGroup, AnonymousUser class ComAlertTest(TestCase): def test_page_is_working(self): self.client.login(username="comunity", password="plop") response = self.client.get(reverse("com:alert_edit")) self.assertNotEqual(response.status_code, 500) self.assertEqual(response.status_code, 200) class ComInfoTest(TestCase): def test_page_is_working(self): self.client.login(username="comunity", password="plop") response = self.client.get(reverse("com:info_edit")) self.assertNotEqual(response.status_code, 500) self.assertEqual(response.status_code, 200) class ComTest(TestCase): @classmethod def setUpTestData(cls): cls.skia = User.objects.filter(username="skia").first() cls.com_group = RealGroup.objects.filter( id=settings.SITH_GROUP_COM_ADMIN_ID ).first() cls.skia.groups.set([cls.com_group]) cls.skia.save() def setUp(self): self.client.login(username=self.skia.username, password="plop") def test_alert_msg(self): response = self.client.post( reverse("com:alert_edit"), { "alert_msg": """ ### ALERTE! **Caaaataaaapuuuulte!!!!** """ }, ) r = self.client.get(reverse("core:index")) self.assertTrue(r.status_code == 200) self.assertContains( r, """
Caaaataaaapuuuulte!!!!
""", ) def test_info_msg(self): response = self.client.post( reverse("com:info_edit"), { "info_msg": """ ### INFO: **Caaaataaaapuuuulte!!!!** """ }, ) r = self.client.get(reverse("core:index")) self.assertTrue(r.status_code == 200) self.assertContains( r, """