File: test_init.py

package info (click to toggle)
python-umodbus 1.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: python: 1,944; makefile: 166; sh: 5
file content (22 lines) | stat: -rw-r--r-- 611 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

from umodbus.server.serial import AbstractSerialServer


@pytest.fixture
def abstract_serial_server():
    return AbstractSerialServer()


def test_abstract_serial_server_get_meta_data(abstract_serial_server):
    """ Test if meta data is correctly extracted from request. """
    assert abstract_serial_server.get_meta_data(b'\x01x\02\x03') ==\
        {'unit_id': 1}


def test_abract_serial_server_shutdown(abstract_serial_server):
    assert abstract_serial_server._shutdown_request is False

    abstract_serial_server.shutdown()

    assert abstract_serial_server._shutdown_request is True