forked from breatheco-de/apiv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
208 additions
and
5 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
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,99 @@ | ||
""" | ||
Test mentorships | ||
""" | ||
|
||
import pytest | ||
|
||
from breathecode.mentorship.admin import use_daily | ||
from capyc.rest_framework import pytest as capy | ||
|
||
|
||
@pytest.mark.fixture(autouse=True) | ||
def setup(db): | ||
yield | ||
|
||
|
||
@pytest.mark.parametrize("model_path", ["mentorship.MentorshipService", "mentorship.AcademyMentorshipSettings"]) | ||
def test_no_items(database: capy.Database, model_path: str): | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_daily(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [] | ||
|
||
|
||
@pytest.mark.django_db(reset_sequences=True) | ||
@pytest.mark.parametrize( | ||
"model_path, model_name, includes_academy", | ||
[ | ||
("mentorship.MentorshipService", "mentorship_service", False), | ||
("mentorship.AcademyMentorshipSettings", "academy_mentorship_settings", True), | ||
], | ||
) | ||
def test_two_items__changed( | ||
database: capy.Database, model_path: str, model_name: str, format: capy.Format, includes_academy: bool | ||
): | ||
extra = { | ||
"city": 1, | ||
"country": 1, | ||
} | ||
|
||
if includes_academy: | ||
extra["academy"] = (2, {"name": "Test Academy"}) | ||
extra[model_name] = [{"video_provider": "GOOGLE_MEET", "academy_id": n + 1} for n in range(2)] | ||
|
||
else: | ||
extra[model_name] = (2, {"video_provider": "GOOGLE_MEET"}) | ||
|
||
model = database.create(**extra) | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_daily(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [ | ||
{ | ||
**format.to_obj_repr(model[model_name][n]), | ||
"video_provider": "DAILY", | ||
} | ||
for n in range(2) | ||
] | ||
|
||
|
||
@pytest.mark.django_db(reset_sequences=True) | ||
@pytest.mark.parametrize( | ||
"model_path, model_name, includes_academy", | ||
[ | ||
("mentorship.MentorshipService", "mentorship_service", False), | ||
("mentorship.AcademyMentorshipSettings", "academy_mentorship_settings", True), | ||
], | ||
) | ||
def test_two_items__did_not_changed( | ||
database: capy.Database, model_path: str, model_name: str, format: capy.Format, includes_academy: bool | ||
): | ||
extra = { | ||
"city": 1, | ||
"country": 1, | ||
} | ||
|
||
if includes_academy: | ||
extra["academy"] = (2, {"name": "Test Academy"}) | ||
extra[model_name] = [{"video_provider": "DAILY", "academy_id": n + 1} for n in range(2)] | ||
|
||
else: | ||
extra[model_name] = (2, {"video_provider": "DAILY"}) | ||
|
||
model = database.create(**extra) | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_daily(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [ | ||
{ | ||
**format.to_obj_repr(model[model_name][n]), | ||
"video_provider": "DAILY", | ||
} | ||
for n in range(2) | ||
] |
99 changes: 99 additions & 0 deletions
99
breathecode/mentorship/tests/admin/tests_use_google_meet.py
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,99 @@ | ||
""" | ||
Test mentorships | ||
""" | ||
|
||
import pytest | ||
|
||
from breathecode.mentorship.admin import use_google_meet | ||
from capyc.rest_framework import pytest as capy | ||
|
||
|
||
@pytest.mark.fixture(autouse=True) | ||
def setup(db): | ||
yield | ||
|
||
|
||
@pytest.mark.parametrize("model_path", ["mentorship.MentorshipService", "mentorship.AcademyMentorshipSettings"]) | ||
def test_no_items(database: capy.Database, model_path: str): | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_google_meet(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [] | ||
|
||
|
||
@pytest.mark.django_db(reset_sequences=True) | ||
@pytest.mark.parametrize( | ||
"model_path, model_name, includes_academy", | ||
[ | ||
("mentorship.MentorshipService", "mentorship_service", False), | ||
("mentorship.AcademyMentorshipSettings", "academy_mentorship_settings", True), | ||
], | ||
) | ||
def test_two_items__changed( | ||
database: capy.Database, model_path: str, model_name: str, format: capy.Format, includes_academy: bool | ||
): | ||
extra = { | ||
"city": 1, | ||
"country": 1, | ||
} | ||
|
||
if includes_academy: | ||
extra["academy"] = (2, {"name": "Test Academy"}) | ||
extra[model_name] = [{"video_provider": "DAILY", "academy_id": n + 1} for n in range(2)] | ||
|
||
else: | ||
extra[model_name] = (2, {"video_provider": "DAILY"}) | ||
|
||
model = database.create(**extra) | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_google_meet(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [ | ||
{ | ||
**format.to_obj_repr(model[model_name][n]), | ||
"video_provider": "GOOGLE_MEET", | ||
} | ||
for n in range(2) | ||
] | ||
|
||
|
||
@pytest.mark.django_db(reset_sequences=True) | ||
@pytest.mark.parametrize( | ||
"model_path, model_name, includes_academy", | ||
[ | ||
("mentorship.MentorshipService", "mentorship_service", False), | ||
("mentorship.AcademyMentorshipSettings", "academy_mentorship_settings", True), | ||
], | ||
) | ||
def test_two_items__did_not_changed( | ||
database: capy.Database, model_path: str, model_name: str, format: capy.Format, includes_academy: bool | ||
): | ||
extra = { | ||
"city": 1, | ||
"country": 1, | ||
} | ||
|
||
if includes_academy: | ||
extra["academy"] = (2, {"name": "Test Academy"}) | ||
extra[model_name] = [{"video_provider": "GOOGLE_MEET", "academy_id": n + 1} for n in range(2)] | ||
|
||
else: | ||
extra[model_name] = (2, {"video_provider": "GOOGLE_MEET"}) | ||
|
||
model = database.create(**extra) | ||
Model = database.get_model(model_path) | ||
queryset = Model.objects.filter() | ||
|
||
use_google_meet(None, None, queryset) | ||
|
||
assert database.list_of(model_path) == [ | ||
{ | ||
**format.to_obj_repr(model[model_name][n]), | ||
"video_provider": "GOOGLE_MEET", | ||
} | ||
for n in range(2) | ||
] |