This Project contain two main part; Reddit and News. I used rest-framework-django to build APIs.
I would clarify the two part as below.
Firstly, for testing the Reddit APIs, I made a Script app in Reddit. Also, for using Reddit APIs, I used Praw Package. Necessary Username, ClientID and Passwords for authorization is included in Praw.ini.
For testing the News API, NewsAPIClient have been used which necessary Secret Key for authorization is included in venv/bin/activate which after activation of Virtual Environment would be exported as Environment Variable and I would obtain this secret key in setting.py file. Request method is โgetโ. News API is only following one function for calling and collecting news. If this function is out of query, would return all the news, but if there was a query, would search and collect all the news tagged as that query.
In this app, there are several Unit Test, examines situations such as redirect or assess the response.
In this unit test I send 500 requests to the server with diffrent words as parameter. because these apps in reddit and newsapi are testing apps it may get some errors such as "you are not allowed to send more than 500 in 12 hours". I add handle exception for these cases and also in this unit test I print duration of each request in app.log file for 50 requests.
For documentation of APIs, django-rest-swagger has been used that could be looked at /docs.
pip install -r requirements.txt
2-copy the below lines at the end of praw.ini, in praw packages that installed in $VIRTUALENV/lib/python3.6/site-packages
[user]
client_id=zmHMvdl7_V6jOg
client_secret=_-lUyJsY3c9Op0s-l_Ox2-DLz4o
password=asddsahadiz
username=hadizamani77
export NEWS_API_SECRET_KEY="52ec1647432f4428ac6c80f23b1a3513"