Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
decon-harsh committed Mar 7, 2021
1 parent 86d4a53 commit 129064c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Make sure you have installed the following:

Next follow these instructions.

1.1 **Database Setup:** Before starting with the project create a db in you local using PostgreSQL with the following details. Refer to `main/settings.py` if you have any confusion.
1. **Database Setup:** Before starting with the project create a db in you local using PostgreSQL with the following details. Refer to `main/settings.py` if you have any confusion.

```
NAME: osp
Expand Down Expand Up @@ -139,7 +139,7 @@ export SENDGRID_API_KEY=<your-sendgrid-api-key>
## Testing
**Test Database:**
You may run the following commands:
For creating a database while testing you have to give database creation permission to user `osp`. You may run the following commands:
```
cd open-source-programs-backend
Expand Down
9 changes: 6 additions & 3 deletions osp/utils/zulip_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# By default the API key file you download is named as 'download' by Zulip. You can place
# this file one directory previous to the cuurent directory your file is in

def get_self_zulip_id():
result = client.get_profile()
return result["user_id"]

def get_client():
return Client(config_file="download")


def get_self_zulip_id():
client = get_client()
result = client.get_profile()
return result["user_id"]


def get_zulip_user(zulip_id: int) -> dict:
"""Takes the zulip user ID as an argument and returns a dictionary containing
basic data on the Zulip user associated with that id
Expand Down
7 changes: 4 additions & 3 deletions tests/test_api_user_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.auth import get_user_model
from rest_framework import status
from rest_framework.test import APIClient, APITestCase

from osp.utils.zulip_api import get_self_zulip_id

User = get_user_model()
Expand Down Expand Up @@ -58,12 +59,12 @@ def test_get_user_info_successfully(self):
body = {"name": "Test User 1 Full Name", "user_type": "admin", "zulip_id": self.zulip_id}
response = self.client.post("http://localhost:8000/api/info/", body, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertNotEqual(response.data,[])
self.assertNotEqual(response.data, [])

response = self.client.get("http://localhost:8000/api/info/", format="json")
response.data = response.data[0]
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertNotEqual(response.data,[])
self.assertNotEqual(response.data, [])
self.assertEqual(response.data["name"], body["name"])
self.assertEqual(response.data["user_type"], body["user_type"])
self.assertEqual(response.data["zulip_id"], body["zulip_id"])
Expand Down

0 comments on commit 129064c

Please sign in to comment.