10
10
class NotImplementedTestMultidrop :
11
11
"""Test that server works on a multidrop line."""
12
12
13
- slaves = [2 ]
14
-
15
13
good_frame = b"\x02 \x03 \x00 \x01 \x00 }\xd4 \x18 "
16
14
17
15
@pytest .fixture (name = "framer" )
18
16
def fixture_framer (self ):
19
17
"""Prepare framer."""
20
- return FramerRTU (ServerDecoder (), [0 ])
18
+ return FramerRTU (ServerDecoder (), [2 ])
21
19
22
20
@pytest .fixture (name = "callback" )
23
21
def fixture_callback (self ):
@@ -27,25 +25,25 @@ def fixture_callback(self):
27
25
def test_ok_frame (self , framer , callback ):
28
26
"""Test ok frame."""
29
27
serial_event = self .good_frame
30
- framer .processIncomingPacket (serial_event , callback , self . slaves )
28
+ framer .processIncomingPacket (serial_event , callback )
31
29
callback .assert_called_once ()
32
30
33
31
def test_ok_2frame (self , framer , callback ):
34
32
"""Test ok frame."""
35
33
serial_event = self .good_frame + self .good_frame
36
- framer .processIncomingPacket (serial_event , callback , self . slaves )
34
+ framer .processIncomingPacket (serial_event , callback )
37
35
assert callback .call_count == 2
38
36
39
37
def test_bad_crc (self , framer , callback ):
40
38
"""Test bad crc."""
41
39
serial_event = b"\x02 \x03 \x00 \x01 \x00 }\xd4 \x19 " # Manually mangled crc
42
- framer .processIncomingPacket (serial_event , callback , self . slaves )
40
+ framer .processIncomingPacket (serial_event , callback )
43
41
callback .assert_not_called ()
44
42
45
43
def test_wrong_id (self , framer , callback ):
46
44
"""Test frame wrong id."""
47
45
serial_event = b"\x01 \x03 \x00 \x01 \x00 }\xd4 +" # Frame with good CRC but other id
48
- framer .processIncomingPacket (serial_event , callback , self . slaves )
46
+ framer .processIncomingPacket (serial_event , callback )
49
47
callback .assert_not_called ()
50
48
51
49
def test_big_split_response_frame_from_other_id (self , framer , callback ):
@@ -64,67 +62,67 @@ def test_big_split_response_frame_from_other_id(self, framer, callback):
64
62
b"\x00 \x00 \x00 \x00 \x00 \x00 \x00 N," ,
65
63
]
66
64
for serial_event in serial_events :
67
- framer .processIncomingPacket (serial_event , callback , self . slaves )
65
+ framer .processIncomingPacket (serial_event , callback )
68
66
callback .assert_not_called ()
69
67
70
68
def test_split_frame (self , framer , callback ):
71
69
"""Test split frame."""
72
70
serial_events = [self .good_frame [:5 ], self .good_frame [5 :]]
73
71
for serial_event in serial_events :
74
- framer .processIncomingPacket (serial_event , callback , self . slaves )
72
+ framer .processIncomingPacket (serial_event , callback )
75
73
callback .assert_called_once ()
76
74
77
75
def test_complete_frame_trailing_data_without_id (self , framer , callback ):
78
76
"""Test trailing data."""
79
77
garbage = b"\x05 \x04 \x03 " # without id
80
78
serial_event = garbage + self .good_frame
81
- framer .processIncomingPacket (serial_event , callback , self . slaves )
79
+ framer .processIncomingPacket (serial_event , callback )
82
80
callback .assert_called_once ()
83
81
84
82
def test_complete_frame_trailing_data_with_id (self , framer , callback ):
85
83
"""Test trailing data."""
86
84
garbage = b"\x05 \x04 \x03 \x02 \x01 \x00 " # with id
87
85
serial_event = garbage + self .good_frame
88
- framer .processIncomingPacket (serial_event , callback , self . slaves )
86
+ framer .processIncomingPacket (serial_event , callback )
89
87
callback .assert_called_once ()
90
88
91
89
def test_split_frame_trailing_data_with_id (self , framer , callback ):
92
90
"""Test split frame."""
93
91
garbage = b"\x05 \x04 \x03 \x02 \x01 \x00 "
94
92
serial_events = [garbage + self .good_frame [:5 ], self .good_frame [5 :]]
95
93
for serial_event in serial_events :
96
- framer .processIncomingPacket (serial_event , callback , self . slaves )
94
+ framer .processIncomingPacket (serial_event , callback )
97
95
callback .assert_called_once ()
98
96
99
97
def test_coincidental_1 (self , framer , callback ):
100
98
"""Test conincidental."""
101
99
garbage = b"\x02 \x90 \x07 "
102
100
serial_events = [garbage , self .good_frame [:5 ], self .good_frame [5 :]]
103
101
for serial_event in serial_events :
104
- framer .processIncomingPacket (serial_event , callback , self . slaves )
102
+ framer .processIncomingPacket (serial_event , callback )
105
103
callback .assert_called_once ()
106
104
107
105
def test_coincidental_2 (self , framer , callback ):
108
106
"""Test conincidental."""
109
107
garbage = b"\x02 \x10 \x07 "
110
108
serial_events = [garbage , self .good_frame [:5 ], self .good_frame [5 :]]
111
109
for serial_event in serial_events :
112
- framer .processIncomingPacket (serial_event , callback , self . slaves )
110
+ framer .processIncomingPacket (serial_event , callback )
113
111
callback .assert_called_once ()
114
112
115
113
def test_coincidental_3 (self , framer , callback ):
116
114
"""Test conincidental."""
117
115
garbage = b"\x02 \x10 \x07 \x10 "
118
116
serial_events = [garbage , self .good_frame [:5 ], self .good_frame [5 :]]
119
117
for serial_event in serial_events :
120
- framer .processIncomingPacket (serial_event , callback , self . slaves )
118
+ framer .processIncomingPacket (serial_event , callback )
121
119
callback .assert_called_once ()
122
120
123
121
def test_wrapped_frame (self , framer , callback ):
124
122
"""Test wrapped frame."""
125
123
garbage = b"\x05 \x04 \x03 \x02 \x01 \x00 "
126
124
serial_event = garbage + self .good_frame + garbage
127
- framer .processIncomingPacket (serial_event , callback , self . slaves )
125
+ framer .processIncomingPacket (serial_event , callback )
128
126
129
127
# We probably should not respond in this case; in this case we've likely become desynchronized
130
128
# i.e. this probably represents a case where a command came for us, but we didn't get
@@ -136,7 +134,7 @@ def test_frame_with_trailing_data(self, framer, callback):
136
134
"""Test trailing data."""
137
135
garbage = b"\x05 \x04 \x03 \x02 \x01 \x00 "
138
136
serial_event = self .good_frame + garbage
139
- framer .processIncomingPacket (serial_event , callback , self . slaves )
137
+ framer .processIncomingPacket (serial_event , callback )
140
138
141
139
# We should not respond in this case for identical reasons as test_wrapped_frame
142
140
callback .assert_called_once ()
@@ -152,23 +150,23 @@ def test_callback(data):
152
150
result = data .function_code .to_bytes (1 ,'big' )+ data .encode ()
153
151
154
152
framer_ok = b"\x02 \x03 \x00 \x01 \x00 \x7d \xd4 \x18 "
155
- framer .processIncomingPacket (framer_ok , test_callback , self . slaves )
153
+ framer .processIncomingPacket (framer_ok , test_callback )
156
154
assert framer_ok [1 :- 2 ] == result
157
155
158
156
count = 0
159
157
framer_2ok = framer_ok + framer_ok
160
- framer .processIncomingPacket (framer_2ok , test_callback , self . slaves )
158
+ framer .processIncomingPacket (framer_2ok , test_callback )
161
159
assert count == 2
162
160
assert not framer ._buffer # pylint: disable=protected-access
163
161
164
162
framer ._buffer = framer_ok [:2 ] # pylint: disable=protected-access
165
- framer .processIncomingPacket (b'' , test_callback , self . slaves )
163
+ framer .processIncomingPacket (b'' , test_callback )
166
164
assert framer_ok [:2 ] == framer ._buffer # pylint: disable=protected-access
167
165
168
166
framer ._buffer = framer_ok [:3 ] # pylint: disable=protected-access
169
- framer .processIncomingPacket (b'' , test_callback , self . slaves )
167
+ framer .processIncomingPacket (b'' , test_callback )
170
168
assert framer_ok [:3 ] == framer ._buffer # pylint: disable=protected-access
171
169
172
170
framer_ok = b"\xF0 \x03 \x00 \x01 \x00 }\xd4 \x18 "
173
- framer .processIncomingPacket (framer_ok , test_callback , self . slaves )
171
+ framer .processIncomingPacket (framer_ok , test_callback )
174
172
assert framer ._buffer == framer_ok [- 3 :] # pylint: disable=protected-access
0 commit comments