Skip to content

Commit d6fa886

Browse files
committed
docs: cover URLs generation topic
1 parent f923c4c commit d6fa886

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ The User Guide
6060
usage/function_imports.rst
6161
usage/metadata.rst
6262
usage/advanced.rst
63+
usage/urls.rst

docs/usage/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ The User Guide
99
* [Function Imports](function_imports.rst)
1010
* [Metadata](metadata.rst)
1111
* [Advanced](advanced.rst)
12+
* [URLs](urls.rst)

docs/usage/urls.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
URLs generation
2+
===============
3+
4+
.. _Locust: https://docs.locust.io/en/stable/
5+
6+
Sometimes you may want to not use **PyOData** to actually make the HTTP requests, but
7+
just grab the url and body for some other library. For that, you can use following
8+
methods from ODataHttpRequest class - which is base of every query, update or delete
9+
covered in pyodata documentation.
10+
11+
.. code-block:: python
12+
13+
.get_method()
14+
.get_path()
15+
.get_query_params()
16+
.get_body()
17+
18+
Locust integration example
19+
--------------------------
20+
**Warning** - execute load testing scripts only against service you own!
21+
22+
Following is example of integration of pyodata as url provider for Locust_ load testing tool.
23+
24+
.. code-block:: python
25+
26+
import requests
27+
import pyodata
28+
from locust import HttpUser, task, between
29+
SERVICE_URL = 'http://services.odata.org/V2/Northwind/Northwind.svc/'
30+
31+
odataClient = pyodata.Client(SERVICE_URL, requests.Session())
32+
smith_employees_query = odataClient.entity_sets.Employees.get_entities().filter("FirstName eq 'John' and LastName eq 'Smith'")
33+
34+
class MyUser(HttpUser):
35+
wait_time = between(5, 15)
36+
host = SERVICE_URL
37+
38+
@task(1)
39+
def filter_query(self):
40+
urlpath = smith_employees_query.get_path()
41+
url = SERVICE_URL + urlpath
42+
params = smith_employees_query.get_query_params()
43+
self.client.get(url,params=params)

0 commit comments

Comments
 (0)