|
19 | 19 | # limitations under the License. |
20 | 20 |
|
21 | 21 |
|
| 22 | +import pytest |
22 | 23 | from neo4j.io._bolt4x0 import Bolt4x0 |
23 | 24 |
|
24 | | - |
25 | 25 | def test_conn_timed_out(fake_socket): |
26 | 26 | address = ("127.0.0.1", 7687) |
27 | 27 | connection = Bolt4x0(address, fake_socket(address), max_age=0) |
@@ -75,55 +75,85 @@ def test_n_extra_in_discard(fake_socket): |
75 | 75 | tag, fields = socket.pop_message() |
76 | 76 | assert tag == b"\x2F" |
77 | 77 | assert len(fields) == 1 |
78 | | - assert fields[0] == {"n": 666, "qid": -1} |
| 78 | + assert fields[0] == {"n": 666} |
79 | 79 |
|
80 | 80 |
|
81 | | -def test_qid_extra_in_discard(fake_socket): |
| 81 | +@pytest.mark.parametrize( |
| 82 | + "test_input, expected", |
| 83 | + [ |
| 84 | + (666, {"n": -1, "qid": 666}), |
| 85 | + (-1, {"n": -1}), |
| 86 | + ] |
| 87 | +) |
| 88 | +def test_qid_extra_in_discard(fake_socket, test_input, expected): |
82 | 89 | address = ("127.0.0.1", 7687) |
83 | 90 | socket = fake_socket(address) |
84 | 91 | connection = Bolt4x0(address, socket) |
85 | | - connection.discard(qid=666) |
| 92 | + connection.discard(qid=test_input) |
86 | 93 | connection.send_all() |
87 | 94 | tag, fields = socket.pop_message() |
88 | 95 | assert tag == b"\x2F" |
89 | 96 | assert len(fields) == 1 |
90 | | - assert fields[0] == {"n": -1, "qid": 666} |
91 | | - |
92 | | - |
93 | | -def test_n_and_qid_extras_in_discard(fake_socket): |
| 97 | + assert fields[0] == expected |
| 98 | + |
| 99 | + |
| 100 | +@pytest.mark.parametrize( |
| 101 | + "test_input, expected", |
| 102 | + [ |
| 103 | + (777, {"n": 666, "qid": 777}), |
| 104 | + (-1, {"n": 666}), |
| 105 | + ] |
| 106 | +) |
| 107 | +def test_n_and_qid_extras_in_discard(fake_socket, test_input, expected): |
| 108 | + # python -m pytest tests/unit/io/test_class_bolt4x0.py -s -k test_n_and_qid_extras_in_discard |
94 | 109 | address = ("127.0.0.1", 7687) |
95 | 110 | socket = fake_socket(address) |
96 | 111 | connection = Bolt4x0(address, socket) |
97 | | - connection.discard(n=666, qid=777) |
| 112 | + connection.discard(n=666, qid=test_input) |
98 | 113 | connection.send_all() |
99 | 114 | tag, fields = socket.pop_message() |
100 | 115 | assert tag == b"\x2F" |
101 | 116 | assert len(fields) == 1 |
102 | | - assert fields[0] == {"n": 666, "qid": 777} |
| 117 | + assert fields[0] == expected |
103 | 118 |
|
104 | 119 |
|
105 | | -def test_n_extra_in_pull(fake_socket): |
| 120 | +@pytest.mark.parametrize( |
| 121 | + "test_input, expected", |
| 122 | + [ |
| 123 | + (666, {"n": 666}), |
| 124 | + (-1, {"n": -1}), |
| 125 | + ] |
| 126 | +) |
| 127 | +def test_n_extra_in_pull(fake_socket, test_input, expected): |
106 | 128 | address = ("127.0.0.1", 7687) |
107 | 129 | socket = fake_socket(address) |
108 | 130 | connection = Bolt4x0(address, socket) |
109 | | - connection.pull(n=666) |
| 131 | + connection.pull(n=test_input) |
110 | 132 | connection.send_all() |
111 | 133 | tag, fields = socket.pop_message() |
112 | 134 | assert tag == b"\x3F" |
113 | 135 | assert len(fields) == 1 |
114 | | - assert fields[0] == {"n": 666, "qid": -1} |
115 | | - |
116 | | - |
117 | | -def test_qid_extra_in_pull(fake_socket): |
| 136 | + assert fields[0] == expected |
| 137 | + |
| 138 | + |
| 139 | +@pytest.mark.parametrize( |
| 140 | + "test_input, expected", |
| 141 | + [ |
| 142 | + (777, {"n": -1, "qid": 777}), |
| 143 | + (-1, {"n": -1}), |
| 144 | + ] |
| 145 | +) |
| 146 | +def test_qid_extra_in_pull(fake_socket, test_input, expected): |
| 147 | + # python -m pytest tests/unit/io/test_class_bolt4x0.py -s -k test_qid_extra_in_pull |
118 | 148 | address = ("127.0.0.1", 7687) |
119 | 149 | socket = fake_socket(address) |
120 | 150 | connection = Bolt4x0(address, socket) |
121 | | - connection.pull(qid=666) |
| 151 | + connection.pull(qid=test_input) |
122 | 152 | connection.send_all() |
123 | 153 | tag, fields = socket.pop_message() |
124 | 154 | assert tag == b"\x3F" |
125 | 155 | assert len(fields) == 1 |
126 | | - assert fields[0] == {"n": -1, "qid": 666} |
| 156 | + assert fields[0] == expected |
127 | 157 |
|
128 | 158 |
|
129 | 159 | def test_n_and_qid_extras_in_pull(fake_socket): |
|
0 commit comments