mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-22 01:58:21 +02:00
Cover also settings files, keep 100% coverage by ignoring production files
This commit is contained in:
@ -11,7 +11,7 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
Matrix.set_display_name("Bot des Correspondances")
|
||||
|
||||
if not os.path.isfile(".matrix_avatar"):
|
||||
if not os.path.isfile(".matrix_avatar"): # pragma: no cover
|
||||
stat_file = os.stat("corres2math/static/logo.png")
|
||||
with open("corres2math/static/logo.png", "rb") as f:
|
||||
resp, _ = Matrix.upload(f, filename="logo.png", content_type="image/png", filesize=stat_file.st_size)
|
||||
@ -21,9 +21,9 @@ class Command(BaseCommand):
|
||||
with open(".matrix_avatar", "w") as f:
|
||||
f.write(avatar_uri)
|
||||
Matrix.set_avatar(avatar_uri)
|
||||
else:
|
||||
with open(".matrix_avatar", "r") as f:
|
||||
avatar_uri = f.read().rstrip(" \t\r\n")
|
||||
|
||||
with open(".matrix_avatar", "r") as f:
|
||||
avatar_uri = f.read().rstrip(" \t\r\n")
|
||||
|
||||
if not async_to_sync(Matrix.resolve_room_alias)("#faq:correspondances-maths.fr"):
|
||||
Matrix.create_room(
|
||||
|
@ -27,7 +27,7 @@ def register_phases(apps, schema_editor):
|
||||
)
|
||||
|
||||
|
||||
def reverse_phase_registering(apps, schema_editor):
|
||||
def reverse_phase_registering(apps, _): # pragma: no cover
|
||||
"""
|
||||
Drop all phases in order to unapply this migration.
|
||||
"""
|
||||
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
@ -652,6 +653,14 @@ class TestStudentParticipation(TestCase):
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Unauthenticated user can't update the calendar
|
||||
self.client.logout()
|
||||
response = self.client.get(reverse("participation:calendar"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
response = self.client.get(reverse("participation:update_phase", args=(2,)))
|
||||
self.assertRedirects(response, reverse("login") + "?next=" +
|
||||
reverse("participation:update_phase", args=(2,)), 302, 200)
|
||||
|
||||
def test_forbidden_access(self):
|
||||
"""
|
||||
Load personnal pages and ensure that these are protected.
|
||||
@ -682,6 +691,22 @@ class TestStudentParticipation(TestCase):
|
||||
resp = self.client.get(reverse("participation:delete_question", args=(question.pk,)))
|
||||
self.assertEqual(resp.status_code, 403)
|
||||
|
||||
def test_cover_matrix(self):
|
||||
"""
|
||||
Load matrix scripts, to cover them and ensure that they can run.
|
||||
"""
|
||||
self.user.registration.team = self.team
|
||||
self.user.registration.save()
|
||||
self.second_user.registration.team = self.second_team
|
||||
self.second_user.registration.save()
|
||||
self.team.participation.valid = True
|
||||
self.team.participation.received_participation = self.second_team.participation
|
||||
self.team.participation.save()
|
||||
|
||||
call_command('fix_matrix_channels')
|
||||
call_command('setup_third_phase')
|
||||
os.remove(".matrix_avatar")
|
||||
|
||||
|
||||
class TestAdmin(TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
Reference in New Issue
Block a user