Skip to content

Commit

Permalink
Bug fix for #1662
Browse files Browse the repository at this point in the history
  • Loading branch information
fhydralisk committed Jul 18, 2023
1 parent 9c425aa commit 6b93d92
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def __init__(
broadcast_enable=False,
response_manipulator=None,
request_tracer=None,
**kwargs, # pylint: disable=unused-argument
):
"""Initialize the socket server.
Expand Down
36 changes: 36 additions & 0 deletions test/test_simulator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Test datastore."""
import copy
import json
from unittest.mock import mock_open, patch

import pytest

from pymodbus.datastore import ModbusSimulatorContext
from pymodbus.datastore.simulator import Cell, CellType, Label
from pymodbus.server import ModbusSimulatorServer


FX_READ_BIT = 1
Expand Down Expand Up @@ -94,6 +97,24 @@ class TestSimulator:
"repeat": [{"addr": [0, 48], "to": [49, 147]}],
}

default_server_config = {
"server": {
"comm": "tcp",
"host": "0.0.0.0",
"port": 5020,
"ignore_missing_slaves": False,
"framer": "socket",
"identity": {
"VendorName": "pymodbus",
"ProductCode": "PM",
"VendorUrl": "https://github.com/pymodbus-dev/pymodbus/",
"ProductName": "pymodbus Server",
"ModelName": "pymodbus Server",
"MajorMinorRevision": "3.1.0",
},
},
}

test_registers = [
Cell(),
Cell(),
Expand Down Expand Up @@ -539,3 +560,18 @@ def test_simulator_action_random(self, celltype, minval, maxval):
regs, is_int
)
assert minval <= new_value <= maxval

async def test_init_simulator(self):
"""Test init simulator server"""
with patch(
"builtins.open",
mock_open(
read_data=json.dumps(
{
"server_list": self.default_server_config,
"device_list": {"device": self.default_config},
}
)
),
):
ModbusSimulatorServer()

0 comments on commit 6b93d92

Please sign in to comment.