-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1146 from pycontw/test_attendee
test(attendee): add test cases for attendee apis
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from django.conf import settings | ||
from registry.helper import reg | ||
from attendee.models import Attendee | ||
from core.models import Token | ||
|
||
|
||
@pytest.mark.parametrize('attendee_token,status,num_channel', [ | ||
('123', 400, 0), | ||
('1234', 200, 0), | ||
('1234', 200, 1), | ||
('1234', 200, 2), | ||
]) | ||
@pytest.mark.django_db | ||
def test_attendee(drf_api_client, bare_user, attendee_token, status, num_channel): | ||
token = Token.objects.get_or_create(user=bare_user) | ||
drf_api_client.credentials(HTTP_AUTHORIZATION="Token " + str(token[0])) | ||
attendee = Attendee(token="1234") | ||
attendee.save() # insert to database | ||
# add slug | ||
key_prefix = f"{settings.CONFERENCE_DEFAULT_SLUG}.live." | ||
reg["pycontw-1999.live.r1"] = "video_old_id" # unrelated | ||
for i in range(num_channel): | ||
reg[f"{key_prefix}r{i}"] = f"video_id_{i}" | ||
|
||
# test | ||
response = drf_api_client.post('/api/attendee/verify/', data={"token": attendee_token}) | ||
assert response.status_code == status | ||
if status == 200: | ||
assert len(response.json()["youtube_infos"]) == num_channel |