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
1 parent
7317706
commit 9adf18e
Showing
2 changed files
with
76 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
75 changes: 75 additions & 0 deletions
75
breathecode/provisioning/tests/urls/tests_academy_id_provisioning_profile.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,75 @@ | ||
""" | ||
Test /v1/provisioning/academy/provisioningprofile | ||
""" | ||
|
||
import json | ||
import os | ||
from django.urls.base import reverse_lazy | ||
from rest_framework import status | ||
|
||
from ..mixins import ProvisioningTestCase | ||
|
||
|
||
def get_serializer(provisioning_profile, data={}): | ||
return { | ||
"id": provisioning_profile.id, | ||
"vendor": provisioning_profile.vendor, | ||
"academy": { | ||
"id": provisioning_profile.academy.id, | ||
"name": provisioning_profile.academy.name, | ||
"slug": provisioning_profile.academy.slug, | ||
}, | ||
**data, | ||
} | ||
|
||
|
||
class ProvisioningTestSuite(ProvisioningTestCase): | ||
|
||
# When: no auth | ||
# Then: should return 401 | ||
def test_upload_without_auth(self): | ||
|
||
url = reverse_lazy("provisioning:academy_id_provisioning_profile", kwargs={"academy_id": 1}) | ||
|
||
response = self.client.get(url) | ||
json = response.json() | ||
expected = {"detail": "Authentication credentials were not provided.", "status_code": 401} | ||
|
||
self.assertEqual(json, expected) | ||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) | ||
|
||
def test_no_profiles(self): | ||
|
||
url = reverse_lazy("provisioning:academy_id_provisioning_profile", kwargs={"academy_id": 1}) | ||
|
||
model = self.bc.database.create( | ||
user=1, | ||
profile_academy=1, | ||
) | ||
self.client.force_authenticate(model.user) | ||
|
||
response = self.client.get(url) | ||
json = response.json() | ||
expected = [] | ||
|
||
self.assertEqual(json, expected) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def test_provisioning_profiles(self): | ||
|
||
url = reverse_lazy("provisioning:academy_id_provisioning_profile", kwargs={"academy_id": 1}) | ||
|
||
model = self.bc.database.create( | ||
user=1, | ||
profile_academy=1, | ||
provisioning_profile=1, | ||
vendor=1, | ||
) | ||
self.client.force_authenticate(model.user) | ||
|
||
response = self.client.get(url) | ||
json = response.json() | ||
expected = [get_serializer(model.provisioning_profile)] | ||
|
||
self.assertEqual(json, expected) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) |