Skip to content

Commit ef819fa

Browse files
committed
CHANGELOG
Signed-off-by: Finbarrs Oketunji <f@finbarrs.eu>
1 parent f6f375f commit ef819fa

File tree

4 files changed

+70
-12
lines changed

4 files changed

+70
-12
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.0.1 - 2023-09-21
4+
* Updated: test.py, README.md, and LONG_DESCRIPTION.rst
5+
36
## 1.0.0 - 2023-09-19
47
* New MOT History API
58

LONG_DESCRIPTION.rst

+34-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,46 @@ You can install this package by using the pip tool and installing:
2323

2424
.. code-block:: bash
2525
26-
$ pip install mot-history-api-py-sdk
26+
pip install mot-history-api-py-sdk
2727
2828
Or:
2929

3030
.. code-block:: bash
3131
32-
$ easy_install mot-history-api-py-sdk
32+
easy_install mot-history-api-py-sdk
3333
34+
Install from source with:
35+
36+
.. code-block:: bash
37+
38+
python setup.py install --user
39+
40+
Or, `sudo python setup.py install` to install the package for all users.
41+
42+
Tests
43+
------
44+
45+
Export environment variables:
46+
47+
.. code-block:: bash
48+
export MOT_CLIENT_ID=
49+
export MOT_CLIENT_SECRET=
50+
export MOT_API_KEY=
51+
52+
Now, you can execute this command: `python3 -m test`
53+
54+
Unset the environment variables after completing the tests:
55+
56+
.. code-block:: bash
57+
unset MOT_CLIENT_ID && unset MOT_CLIENT_SECRET && unset MOT_API_KEY
58+
59+
Developers/Engineers can run tests in two scenarios:
60+
61+
+ **With real credentials**: They set the environment variables, and the tests use the live API connection.
62+
63+
+ **Without credentials**: The tests run using a mock client, allowing basic functionality checks without a live API connection.
64+
65+
The flexibility supports real integration testing and quick, credential-free checks during development.
3466

3567
Request MOT History API Key
3668
---------------------------

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ Unset the environment variables after completing the tests:
4646
unset MOT_CLIENT_ID && unset MOT_CLIENT_SECRET && unset MOT_API_KEY
4747
```
4848

49+
Developers/Engineers can run tests in two scenarios:
50+
51+
+ **With real credentials**: They set the environment variables, and the tests use the live API connection.
52+
53+
+ **Without credentials**: The tests run using a mock client, allowing basic functionality checks without a live API connection.
54+
55+
The flexibility supports real integration testing and quick, credential-free checks during development.
56+
4957
### Setting up a MOT History API
5058

5159
You can use this support form to request an [API Key](https://documentation.history.mot.api.gov.uk/mot-history-api/register).

test.py

+25-10
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,35 @@
77
import os
88
import sys
99
from pprint import pprint
10-
from motapi import MOTDataClient
10+
from typing import Optional
11+
from unittest.mock import Mock
1112

12-
# Retrieve credentials from environment variables
13-
CLIENT_ID = os.environ.get("MOT_CLIENT_ID")
14-
CLIENT_SECRET = os.environ.get("MOT_CLIENT_SECRET")
15-
API_KEY = os.environ.get("MOT_API_KEY")
13+
# It attempts to import MOTDataClient
14+
# but falls back to a mock if it is present.
15+
try:
16+
from motapi import MOTDataClient
17+
except ImportError:
18+
MOTDataClient = Mock()
1619

17-
# Please set credentials
18-
if not CLIENT_ID or not CLIENT_SECRET or not API_KEY:
19-
print("Error: Please set MOT_CLIENT_ID, MOT_CLIENT_SECRET, and MOT_API_KEY environment variables.")
20-
sys.exit(1)
20+
# Retrieve credentials from environment variables
21+
CLIENT_ID: Optional[str] = os.environ.get("MOT_CLIENT_ID")
22+
CLIENT_SECRET: Optional[str] = os.environ.get("MOT_CLIENT_SECRET")
23+
API_KEY: Optional[str] = os.environ.get("MOT_API_KEY")
2124

2225
# Initialize the client
23-
client = MOTDataClient(CLIENT_ID, CLIENT_SECRET, API_KEY)
26+
if all([CLIENT_ID, CLIENT_SECRET, API_KEY]):
27+
client = MOTDataClient(
28+
client_id=CLIENT_ID,
29+
client_secret=CLIENT_SECRET,
30+
api_key=API_KEY
31+
)
32+
else:
33+
print("Warning: Using mock client as credentials are not set.")
34+
client = Mock()
35+
# Setup mock responses
36+
client.get_vehicle_data.return_value = {"mock": "vehicle data"}
37+
client.get_bulk_download_info.return_value = {"mock": "bulk download info"}
38+
client.renew_client_secret.return_value = "mock_new_secret"
2439

2540
def test_get_vehicle_data_by_registration():
2641
"""Test retrieving vehicle data by registration number."""

0 commit comments

Comments
 (0)