rename UV to UE

This commit is contained in:
Thomas Girod
2025-04-08 13:48:10 +02:00
committed by imperosol
parent 32570ee03d
commit 775a3282dc
28 changed files with 783 additions and 699 deletions

View File

@@ -9,19 +9,19 @@ from model_bakery.recipe import Recipe
from core.baker_recipes import subscriber_user
from core.models import Group, User
from pedagogy.models import UV
from pedagogy.models import UE
class TestUVSearch(TestCase):
"""Test UV guide rights for view and API."""
class TestUESearch(TestCase):
"""Test UE guide rights for view and API."""
@classmethod
def setUpTestData(cls):
cls.root = User.objects.get(username="root")
cls.url = reverse("api:fetch_uvs")
uv_recipe = Recipe(UV, author=cls.root)
uvs = [
uv_recipe.prepare(
cls.url = reverse("api:fetch_ues")
ue_recipe = Recipe(UE, author=cls.root)
ues = [
ue_recipe.prepare(
code="AP4A",
credit_type="CS",
semester="AUTUMN",
@@ -32,7 +32,7 @@ class TestUVSearch(TestCase):
"Concepts fondamentaux et mise en pratique avec le langage C++"
),
),
uv_recipe.prepare(
ue_recipe.prepare(
code="MT01",
credit_type="CS",
semester="AUTUMN",
@@ -40,10 +40,10 @@ class TestUVSearch(TestCase):
manager="ben",
title="Intégration1. Algèbre linéaire - Fonctions de deux variables",
),
uv_recipe.prepare(
ue_recipe.prepare(
code="PHYS11", credit_type="CS", semester="AUTUMN", department="TC"
),
uv_recipe.prepare(
ue_recipe.prepare(
code="TNEV",
credit_type="TM",
semester="SPRING",
@@ -51,10 +51,10 @@ class TestUVSearch(TestCase):
manager="moss",
title="tnetennba",
),
uv_recipe.prepare(
ue_recipe.prepare(
code="MT10", credit_type="TM", semester="AUTUMN", department="IMSI"
),
uv_recipe.prepare(
ue_recipe.prepare(
code="DA50",
credit_type="TM",
semester="AUTUMN_AND_SPRING",
@@ -62,7 +62,7 @@ class TestUVSearch(TestCase):
manager="francky",
),
]
UV.objects.bulk_create(uvs)
UE.objects.bulk_create(ues)
call_command("update_index")
def test_permissions(self):
@@ -93,7 +93,7 @@ class TestUVSearch(TestCase):
"""Test that the return data format is correct"""
self.client.force_login(self.root)
res = self.client.get(self.url + "?search=PA00")
uv = UV.objects.get(code="PA00")
ue = UE.objects.get(code="PA00")
assert res.status_code == 200
assert json.loads(res.content) == {
"count": 1,
@@ -101,12 +101,12 @@ class TestUVSearch(TestCase):
"previous": None,
"results": [
{
"id": uv.id,
"title": uv.title,
"code": uv.code,
"credit_type": uv.credit_type,
"semester": uv.semester,
"department": uv.department,
"id": ue.id,
"title": ue.title,
"code": ue.code,
"credit_type": ue.credit_type,
"semester": ue.semester,
"department": ue.department,
}
],
}
@@ -114,7 +114,7 @@ class TestUVSearch(TestCase):
def test_search_by_text(self):
self.client.force_login(self.root)
for query, expected in (
# UV code search case insensitive
# UE code search case insensitive
("m", {"MT01", "MT10"}),
("M", {"MT01", "MT10"}),
("mt", {"MT01", "MT10"}),
@@ -126,24 +126,24 @@ class TestUVSearch(TestCase):
):
res = self.client.get(self.url + f"?search={query}")
assert res.status_code == 200
assert {uv["code"] for uv in json.loads(res.content)["results"]} == expected
assert {ue["code"] for ue in json.loads(res.content)["results"]} == expected
def test_search_by_credit_type(self):
self.client.force_login(self.root)
res = self.client.get(self.url + "?credit_type=CS")
assert res.status_code == 200
codes = [uv["code"] for uv in json.loads(res.content)["results"]]
codes = [ue["code"] for ue in json.loads(res.content)["results"]]
assert codes == ["AP4A", "MT01", "PHYS11"]
res = self.client.get(self.url + "?credit_type=CS&credit_type=OM")
assert res.status_code == 200
codes = {uv["code"] for uv in json.loads(res.content)["results"]}
codes = {ue["code"] for ue in json.loads(res.content)["results"]}
assert codes == {"AP4A", "MT01", "PHYS11", "PA00"}
def test_search_by_semester(self):
self.client.force_login(self.root)
res = self.client.get(self.url + "?semester=SPRING")
assert res.status_code == 200
codes = {uv["code"] for uv in json.loads(res.content)["results"]}
codes = {ue["code"] for ue in json.loads(res.content)["results"]}
assert codes == {"DA50", "TNEV", "PA00"}
def test_search_multiple_filters(self):
@@ -152,7 +152,7 @@ class TestUVSearch(TestCase):
self.url + "?semester=AUTUMN&credit_type=CS&department=TC"
)
assert res.status_code == 200
codes = {uv["code"] for uv in json.loads(res.content)["results"]}
codes = {ue["code"] for ue in json.loads(res.content)["results"]}
assert codes == {"MT01", "PHYS11"}
def test_search_fails(self):
@@ -163,15 +163,15 @@ class TestUVSearch(TestCase):
def test_search_pa00_fail(self):
self.client.force_login(self.root)
# Search with UV code
# Search with UE code
response = self.client.get(reverse("pedagogy:guide"), {"search": "IFC"})
self.assertNotContains(response, text="PA00")
# Search with first letter of UV code
# Search with first letter of UE code
response = self.client.get(reverse("pedagogy:guide"), {"search": "I"})
self.assertNotContains(response, text="PA00")
# Search with UV manager
# Search with UE manager
response = self.client.get(reverse("pedagogy:guide"), {"search": "GILLES"})
self.assertNotContains(response, text="PA00")