mirror of
https://github.com/ae-utbm/sith.git
synced 2026-03-22 03:25:05 +00:00
add tests
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from django.test import Client
|
||||||
|
from django.urls import reverse
|
||||||
from django.utils.timezone import localdate
|
from django.utils.timezone import localdate
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
from model_bakery.recipe import Recipe
|
from model_bakery.recipe import Recipe
|
||||||
|
|
||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
from core.baker_recipes import subscriber_user
|
from core.baker_recipes import subscriber_user
|
||||||
|
from core.models import User
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@@ -25,3 +28,10 @@ def test_club_queryset_having_board_member():
|
|||||||
|
|
||||||
club_ids = Club.objects.having_board_member(user).values_list("id", flat=True)
|
club_ids = Club.objects.having_board_member(user).values_list("id", flat=True)
|
||||||
assert set(club_ids) == {clubs[1].id, clubs[2].id}
|
assert set(club_ids) == {clubs[1].id, clubs[2].id}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_club_list(client: Client):
|
||||||
|
client.force_login(baker.make(User))
|
||||||
|
res = client.get(reverse("club:club_list"))
|
||||||
|
assert res.status_code == 200
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ class TestClubSearch(TestCase):
|
|||||||
ids = {d["id"] for d in response.json()["results"]}
|
ids = {d["id"] for d in response.json()["results"]}
|
||||||
assert ids == {c.id for c in [self.clubs[0], self.clubs[1], self.clubs[3]]}
|
assert ids == {c.id for c in [self.clubs[0], self.clubs[1], self.clubs[3]]}
|
||||||
|
|
||||||
|
def test_club_search_profile(self):
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
url = reverse("api:search_club_profile")
|
||||||
|
response = self.client.get(url, {"search": "AE"})
|
||||||
|
assert response.status_code == 200
|
||||||
|
ids = {d["id"] for d in response.json()["results"]}
|
||||||
|
assert ids == {c.id for c in [self.clubs[0], self.clubs[1], self.clubs[3]]}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
class TestFetchClub:
|
class TestFetchClub:
|
||||||
|
|||||||
Reference in New Issue
Block a user