You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-57Lines changed: 84 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,14 @@ This demo project is not cover all test cases for the HTTP operations and all RD
22
22
23
23
## Unit Testing Overview
24
24
25
-
Unit testing is the smallest test that focuses on checking that a single part of the application operates correctly. It breaks an application into the smallest, isolated, testable component called *units*, and then tests them individually. The unit is mostly a function or method call or procedure in the application source code. Developers and QA can test each unit by sending any data into that unit and see if it functions as intended.
25
+
[Unit testing](https://en.wikipedia.org/wiki/Unit_testing) is the smallest test that focuses on checking that a single part of the application operates correctly. It breaks an application into the smallest, isolated, testable component called *units*, and then tests them individually. The unit is mostly a function or method call or procedure in the application source code. Developers and QA can test each unit by sending any data into that unit and see if it functions as intended.
26
26
27
27
A unit test helps developers to isolate what is broken in their application easier and faster than testing an entire system as a whole. It is the first level of testing done during the development process before integration testing. It is mostly done by the developers automated or manually to verify their code.
28
28
29
+
You can find more detail about the unit test concept from the following resources:
30
+
-[Python Guide: Testing Your Code](https://docs.python-guide.org/writing/tests/) article.
31
+
-[How and when to use Unit Testing properly](https://softwareengineering.stackexchange.com/questions/89064/how-and-when-to-use-unit-testing-properly) post.
32
+
29
33
## Introduction to Python Unittest framework
30
34
31
35
The [unittest](https://docs.python.org/3.9/library/unittest.html) is a Python-built unit testing framework. It supports both **test case** (the individual unit of testing) and **test runner** (a special application designed for running test cases and provides the output result).
@@ -157,11 +161,8 @@ class RDPHTTPController():
157
161
self.client_secret = ''
158
162
pass
159
163
160
-
# Send HTTP Post request to get Access Token (Password Grant and Refresh Grant) from RDP Auth Service
164
+
# Send HTTP Post request to get Access Token (Password Grant and Refresh Grant) from the RDP Auth Service
@@ -857,54 +858,80 @@ The test cases for this ```rdp_request_search_explore()``` method have the same
857
858
858
859
That’s all I have to say about unit testing the Python HTTP code with Requests and Responses libraries.
859
860
860
-
## Project Structure
861
-
862
-
## Python run app
863
-
864
-
865
-
## Python Test
866
-
867
-
```
868
-
python -m unittest test_http
869
-
870
-
python -m unittest test_rdp_http_controller
871
-
872
-
python -m unittest discover
873
-
874
-
python -m unittest test_app
875
-
```
876
-
877
-
### Docker
878
-
879
-
```
880
-
docker build . -t python_unittest
881
-
882
-
docker run -it --name python_unittest python_unittest
883
-
```
861
+
## <aid="prerequisite"></a>Prerequisite
862
+
863
+
This demo project requires the following dependencies.
864
+
865
+
1. RDP Access credentials.
866
+
2. Python [Anaconda](https://www.anaconda.com/distribution/) or [MiniConda](https://docs.conda.io/en/latest/miniconda.html) distribution/package manager.
867
+
3.[Docker Desktop/Engine](https://docs.docker.com/get-docker/) application for running the test suite with Docker.
868
+
5. Internet connection.
869
+
870
+
Please contact your Refinitiv representative to help you to access the RDP account and services. You can find more detail regarding the RDP access credentials set up from the lease see the *Getting Started for User ID* section of the [Getting Start with Refinitiv Data Platform](https://developers.refinitiv.com/en/article-catalog/article/getting-start-with-refinitiv-data-platform) article.
871
+
872
+
873
+
## <aid="how_to_run"></a>How to run the example test suite
874
+
875
+
The first step is to unzip or download the example project folder into a directory of your choice, then set up Python or Docker environments based on your preference.
876
+
877
+
### <aid="python_example_run"></a>Run example test suite in a console
878
+
879
+
1. Open Anaconda Prompt and go to the project's folder.
880
+
2. Run the following command in the Anaconda Prompt application to create a Conda environment named *http_unittest* for the project.
3. Once the environment is created, activate a Conda *http_unittest* environment with this command in Anaconda Prompt.
885
+
```
886
+
(base) $>conda activate http_unittest
887
+
```
888
+
4. Run the following command to the dependencies in the *http_unittest* environment
889
+
```
890
+
(http_unittest) $>pip install -r requirements.txt
891
+
```
892
+
5. Once the dependencies installation process success, Go to the project's *tests* folder, then run the following command to run the ```test_rdp_http_controller.py``` test suite.
For further details, please check out the following resources:
920
+
* [Refinitiv Data Platform APIs page](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis) on the [Refinitiv Developer Community](https://developers.refinitiv.com/) website.
921
+
* [Refinitiv Data Platform APIs Playground page](https://api.refinitiv.com).
922
+
* [Refinitiv Data Platform APIs: Introduction to the Request-Response API](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis/tutorials#introduction-to-the-request-response-api).
923
+
* [Refinitiv Data Platform APIs: Authorization - All about tokens](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis/tutorials#authorization-all-about-tokens).
924
+
* [Limitations and Guidelines for the RDP Authentication Service](https://developers.refinitiv.com/en/article-catalog/article/limitations-and-guidelines-for-the-rdp-authentication-service) article.
925
+
* [Getting Started with Refinitiv Data Platform](https://developers.refinitiv.com/en/article-catalog/article/getting-start-with-refinitiv-data-platform) article.
926
+
* [Python unittest framework official page](https://docs.python.org/3/library/unittest.html).
* [Python Guide: Testing Your Code](https://docs.python-guide.org/writing/tests/) article.
929
+
* [Getting Started With Testing in Python](https://realpython.com/python-testing/) article.
930
+
* [Mocking External APIs in Python](https://realpython.com/testing-third-party-apis-with-mocks/) article.
931
+
* [How To Use unittest to Write a Test Case for a Function in Python](https://www.digitalocean.com/community/tutorials/how-to-use-unittest-to-write-a-test-case-for-a-function-in-python) article.
932
+
* [Mocking API calls in Python](https://auth0.com/blog/mocking-api-calls-in-python/) article.
933
+
* [How and when to use Unit Testing properly](https://softwareengineering.stackexchange.com/questions/89064/how-and-when-to-use-unit-testing-properly) post.
934
+
* [13 Tips for Writing Useful Unit Tests](https://betterprogramming.pub/13-tips-for-writing-useful-unit-tests-ca20706b5368) blog post.
935
+
936
+
For any questions related to Refinitiv Data Platform APIs, please use the [RDP APIs Forum](https://community.developers.refinitiv.com/spaces/231/index.html) on the [Developers Community Q&A page](https://community.developers.refinitiv.com/).
0 commit comments