Skip to content

Commit

Permalink
Execute methods of Requests accept context
Browse files Browse the repository at this point in the history
There were errors whenever a request that got handles in
other_message.py got it's execute method called, as it was being called
with a context parameter. The functions now accept this parameter,
although they don't do anything with it.

The tests have also been updated.
  • Loading branch information
Bart de Waal committed Apr 2, 2015
1 parent fec7ac3 commit a2f0d0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pymodbus/other_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def decode(self, data):
'''
pass

def execute(self):
def execute(self, context):
''' Run a read exeception status request against the store
:returns: The populated response
Expand Down Expand Up @@ -143,7 +143,7 @@ def decode(self, data):
'''
pass

def execute(self):
def execute(self, context):
''' Run a read exeception status request against the store
:returns: The populated response
Expand Down Expand Up @@ -248,7 +248,7 @@ def decode(self, data):
'''
pass

def execute(self):
def execute(self, context):
''' Run a read exeception status request against the store
:returns: The populated response
Expand Down Expand Up @@ -358,7 +358,7 @@ def decode(self, data):
'''
pass

def execute(self):
def execute(self, context):
''' Run a read exeception status request against the store
:returns: The populated response
Expand Down
10 changes: 5 additions & 5 deletions test/test_other_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def testReadExceptionStatus(self):
request = ReadExceptionStatusRequest()
request.decode('\x12')
self.assertEqual(request.encode(), '')
self.assertEqual(request.execute().function_code, 0x07)
self.assertEqual(request.execute(None).function_code, 0x07)

response = ReadExceptionStatusResponse(0x12)
self.assertEqual(response.encode(), '\x12')
Expand All @@ -48,7 +48,7 @@ def testGetCommEventCounter(self):
request = GetCommEventCounterRequest()
request.decode('\x12')
self.assertEqual(request.encode(), '')
self.assertEqual(request.execute().function_code, 0x0b)
self.assertEqual(request.execute(None).function_code, 0x0b)

response = GetCommEventCounterResponse(0x12)
self.assertEqual(response.encode(), '\x00\x00\x00\x12')
Expand All @@ -63,7 +63,7 @@ def testGetCommEventLog(self):
request = GetCommEventLogRequest()
request.decode('\x12')
self.assertEqual(request.encode(), '')
self.assertEqual(request.execute().function_code, 0x0c)
self.assertEqual(request.execute(None).function_code, 0x0c)

response = GetCommEventLogResponse()
self.assertEqual(response.encode(), '\x06\x00\x00\x00\x00\x00\x00')
Expand All @@ -89,9 +89,9 @@ def testReportSlaveId(self):
request = ReportSlaveIdRequest()
request.decode('\x12')
self.assertEqual(request.encode(), '')
self.assertEqual(request.execute().function_code, 0x11)
self.assertEqual(request.execute(None).function_code, 0x11)

response = ReportSlaveIdResponse(request.execute().identifier, True)
response = ReportSlaveIdResponse(request.execute(None).identifier, True)
self.assertEqual(response.encode(), '\x0apymodbus\xff')
response.decode('\x03\x12\x00')
self.assertEqual(response.status, False)
Expand Down

0 comments on commit a2f0d0a

Please sign in to comment.