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
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -580,9 +580,10 @@ class RDPHTTPController():
580
580
581
581
The ```rdp_request_esg()``` method above just create the request message payload, and send it to the RDP ESG service as HTTP GET request with the Requests ```requests.get()``` method. The return values can be as follows
582
582
- If the request success (HTTP status is 200), returns the response data in JSON message format.
583
-
- If the URL or credentials parameters are empty or none, raise the TypeError exception to the caller.
583
+
- If the URL or access token, or universe values are empty or none, raise the TypeError exception to the caller.
584
584
- If the request fails, raise the Requests' HTTPError exception to the caller with HTTP status response information.
585
585
586
+
586
587
### Testing a valid RDP ESG Request-Response
587
588
588
589
The first test case is the request success scenario. I will begin by creating a fixture file with a valid ESG dummy response message. A file is *rdp_test_esg_fixture.json* in a *tests/fixtures* folder.
@@ -782,6 +783,9 @@ class TestRDPHTTPController(unittest.TestCase):
782
783
self.assertIn('status', json_error['error'])
783
784
784
785
```
786
+
The other common RDP APIs failure scenarios is the application sends the request message to RDP without the access token in the HTTP request' header. However, the *access token* is one of the ```rdp_request_esg()``` method required parameters. If the access token is not presented (None or Empty), the method raise the TypeError exception and not send HTTP request message to the RDP. The ```test_request_esg_none_empty()``` method is the one that covers this test case.
787
+
788
+
785
789
### Testing Requesting RDP ESG data with an invalid item
786
790
787
791
Now we come to other common test cases, what if users request invalid item name data from the RDP ESG service? We can use a mock object to simulate invalid item request-response messages too.
@@ -845,7 +849,7 @@ That covers all I wanted to say about unit testing the HTTP requests for the RDP
845
849
The source code that uses the Request library ```requests.post()``` method to send HTTP POST request message to the RDP Search Explore is available at the ```rdp_request_search_explore()``` method of the ```rdp_controller/rdp_http_controller.py``` class.
846
850
847
851
The test cases for this ```rdp_request_search_explore()``` method have the same testing and mocking logic as all previous cases that I have mentions above. You can find more details in the following test cases methods:
848
-
- ```test_request_search_explore()```` method: Unit testing a valid request-response
852
+
-```test_request_search_explore()``` method: Unit testing a valid request-response
849
853
-```test_request_search_explore_token_expire()``` method: Unit testing a token expired case
850
854
-```test_request_search_explore_invalid_ric()``` method: Unit testing an invalid ric case
851
855
-```test_request_search_explore_invalid_json()``` method: Unit testing an invalid JSON post message case
0 commit comments