:warning: WORK IN PROGRESS :warning:
This library is a Python wrapper for accessing Somconnexio's Odoo (Odoo v12 with customizations). More info about the customizations in SomConnexio Odoo module.
Resources
- AssetConsumption - Asset consumption
Installation
$ pip install mm-proxy-python-client
Configuration Environment
You need define the mm-proxy basic autenthication user and password and the host URL as environment variables. You need to define:
MM_PROXY_BASEURL=<YOUR MM-PROXY HOST>/api
MM_PROXY_USER=<YOUR MM-PROXY BASIC AUTH USER>
MM_PROXY_PASSWORD=<YOUR MM-PROXY BASIC AUTH PASSWORD>
If this envvars are not defined, a exception will be raised with the name of the envvar not defined.
Usage
Get mobile consumption
>>> from mm_proxy_python_client.resources.mobile_consumption import MobileConsumption
>>>
>>> consumption = MobileConsumption.get(asset_id="", phone_number="666888999", start_date="2023-12-01", end_date="2023-13-31")
>>> consumption.asset_id
123
>>> consumption.tariffs[0].dataTotal
"10240"
Development
Setup environment
- Install
pyenv
curl https://pyenv.run | bash
- Build the Python version
pyenv install 3.8.13
- Create a virtualenv
pyenv virtualenv 3.8.13 mm-proxy-python-client
- Install dependencies
pyenv exec pip install -r requirements-dev.txt
- Install pre-commit hooks
pyenv exec pre-commit install
Test the HTTP request
We are using the HTTP recording plugin of Pytest: pytest-recording.
With VRC we can catch the HTTP responses and then, execute the tests using them.
To actually call the mm-proxy local client in order to create or rewrite cassettes using the next pyenv commands, we need to first change the conftest.py file and temporally provide the actual mm-proxy user and password.
monkeypatch.setenv("MM_PROXY_PASSWORD", "<ACTUAL_MM_PROXY_PASSWORD>")
⚠️ Do not commit this change!
To add a new test:
- Expose the needed envvars. Look for them at the Configuration Environment section
- Execute the tests using
pytestcommand: - If you are writing a new test that is making requests, you should run:
$ pytest --record-mode=once path/to/your/test
- You might need to record requests for an specific tests. In that case make sure to only run the tests affected and run
$ pytest --record-mode=rewrite path/to/your/test
- Add the new
cassetesto the commit and push them. - The CI uses the cassetes to emulate the HTTP response in the test.
Run test suite
$ tox
Formatting
We use pre-commit to execute Flake8, yamllint (for the cassetes) and Black as formatter.
Release process
Update CHANGELOG.md following this steps:
- Add any entries missing from merged merge requests.
- Duplicate the
[Unreleased]header. - Replace the second
Unreleasedwith a version number followed by the current date. Copy the exact format from previous releases.
Then, you can release and publish the package to PyPi:
- Update the
__version__var in__init__.pymatching the version you specified in the CHANGELOG. - Open a merge request with these changes for the team to approve
- Merge it, add a git tag on that merge commit and push it.
- Once the pipeline has successfully passed, go approve the
publishstep.
Metadata
Release files for mm-proxy-python-client 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mm_proxy_python_client-0.1.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / mm_proxy_python_client-0.1.3-py2.py3-none-any.whl
| Download URL | mm_proxy_python_client-0.1.3-py2.py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8bf916e1f424ed845e7187fc345b764ffdc19c1e0c6a0bd546ceb3f21ccb6a20
|
|
BLAKE2b-256 checksum How to use checksums |
1fe6f849f63c7b8b591fc2bfb1314ab39f9ab401fb4c0bd029b977f5e0b0293f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|