Testing
Tests for meters and iostacks are in the tests directory.
- tests/meter/test_meter.py
Test v3 or v4 meter API.
- tests/iostack/test_iostack.py
Test ioStack API.
Running tests
The tests require a serial connection to the device(s) for which you would like to run the tests.
Installation
It is highy recommended you use a virtualenv.
python -m venv venv
. venv/bin/activate
Install from repository:
python -m pip install https://github.com/ekmmetering/ekmdevice/archive/refs/heads/main.zip[test]
Or get the source and install:
git clone https://github.com/ekmmetering/ekmdevice
cd ekmdevice
pip install .[test]
The pytest usage is:
pytest --<device-type> [[version].]<address>
Meter
Connect a meter to the test machine using a USB-rs485 adapter (available from EKM). In these examples the serial port will be /dev/ttyUSB0 (which is the default if you do not specify a port).
For v4 meters (example meter address 300001317):
pytest --meter v4.300001317 --port /dev/ttyUSB0
ioStack
For ioStack with address of 1:
pytest --iostack 1 --port /dev/ttyUSB0
Both
pytest --meter v4.300001317 pytest --iostack 1 --port /dev/ttyUSB0
- Note: Due to dissimilarities in serial protocol between meters and
iostack devices there are often communication errors with meters when switching serial protocols from iostack devices to meter devices, which cause the first few tests to fail. At this moment it is advisable to test each device type separately.