-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modified: org/responses.py modified: org/urls.py modified: org/views.py new file: tests/org/tests_org_info.py * feat: Added org info API This commit adds the functionality to fetch the information about any organisation by an authorised user, so that users can check the details before joining them. Fixes #120 * Update org/views.py Co-authored-by: Naveen Sundar <[email protected]> * Update org/views.py Co-authored-by: Naveen Sundar <[email protected]> * Update org/views.py Co-authored-by: Naveen Sundar <[email protected]> * feat: Added org info API This commit adds the functionality to fetch the information about any organisation by an authorised user, so that users can check the details before joining them. Fixes #120 * modified: org/responses.py modified: org/urls.py modified: org/views.py new file: tests/org/tests_org_info.py * modified: org/urls.py * modified: org/responses.py modified: org/views.py Co-authored-by: Naveen Sundar <[email protected]>
- Loading branch information
1 parent
ebde2e4
commit 227b764
Showing
4 changed files
with
120 additions
and
84 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
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,43 @@ | ||
from org.models import * | ||
from tests.AuthAPITestCase import AuthAPITestCase | ||
from rest_framework.test import APITestCase, APIClient | ||
from rest_framework import status | ||
from users.models import User | ||
from org.serializers import CreateOrgSerializer | ||
from org.custom_model_field import PermissionField as Permissions | ||
import uuid | ||
|
||
|
||
class GetOrgAPITestCase(AuthAPITestCase): | ||
def setUp(self): | ||
# Inheriting the base class funtionality | ||
super(GetOrgAPITestCase, self).setUp() | ||
|
||
data_org = { | ||
"name": 'test', | ||
"tagline": 'test', | ||
} | ||
serializer = CreateOrgSerializer(data=data_org) | ||
if serializer.is_valid(): | ||
self.org, self.admin_group = serializer.save() | ||
|
||
def test_fail_without_auth(self): | ||
get_org_api = "/api/org/1/" | ||
un_auth_client = APIClient() | ||
response = un_auth_client.get(get_org_api) | ||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) | ||
|
||
def test_fail_with_unknown_org(self): | ||
get_org_api = "/api/org/123123/" | ||
auth_client = self.create_auth_client() | ||
response = auth_client.get(get_org_api) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
def test_pass_with_auth_user(self): | ||
get_org_api = "/api/org/1/" | ||
auth_client = self.create_auth_client() | ||
response = auth_client.get(get_org_api) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def tearDown(self): | ||
super(GetOrgAPITestCase, self).tearDown() |