Skip to content

Commit ea2033d

Browse files
wiegandmbjoernricks
authored andcommitted
Tests: Add tests for current and future GMP versions
Add tests to make sure the detected protocol version and instance is correct for GMP 22.7. Also add tests for the expected next protocol version (`22.8`) and a possible far future version (`22.20`), which should adequately fall back to the latest current version.
1 parent 8f3ea98 commit ea2033d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/protocols/gmp/test_context_manager.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from gvm.protocols.gmp._gmp224 import GMPv224
1212
from gvm.protocols.gmp._gmp225 import GMPv225
1313
from gvm.protocols.gmp._gmp226 import GMPv226
14+
from gvm.protocols.gmp._gmp227 import GMPv227
1415
from tests.protocols import GmpTestCase
1516

1617

@@ -133,6 +134,49 @@ def test_select_gmpv226(self):
133134
self.assertEqual(gmp.get_protocol_version(), (22, 6))
134135
self.assertIsInstance(gmp, GMPv226)
135136

137+
def test_select_gmpv227(self):
138+
self.connection.read.return_value(
139+
b'<get_version_response status="200" status_text="OK">'
140+
b"<version>22.07</version>"
141+
b"</get_version_response>"
142+
)
143+
144+
with self.gmp as gmp:
145+
self.assertEqual(gmp.get_protocol_version(), (22, 7))
146+
self.assertIsInstance(gmp, GMPv227)
147+
148+
self.connection.read.return_value(
149+
b'<get_version_response status="200" status_text="OK">'
150+
b"<version>22.7</version>"
151+
b"</get_version_response>"
152+
)
153+
154+
with self.gmp as gmp:
155+
self.assertEqual(gmp.get_protocol_version(), (22, 7))
156+
self.assertIsInstance(gmp, GMPv227)
157+
158+
def test_next_version_fallback(self):
159+
self.connection.read.return_value(
160+
b'<get_version_response status="200" status_text="OK">'
161+
b"<version>22.8</version>"
162+
b"</get_version_response>"
163+
)
164+
165+
with self.gmp as gmp:
166+
self.assertEqual(gmp.get_protocol_version(), (22, 7))
167+
self.assertIsInstance(gmp, GMPv227)
168+
169+
def test_newer_version_fallback(self):
170+
self.connection.read.return_value(
171+
b'<get_version_response status="200" status_text="OK">'
172+
b"<version>22.20</version>"
173+
b"</get_version_response>"
174+
)
175+
176+
with self.gmp as gmp:
177+
self.assertEqual(gmp.get_protocol_version(), (22, 7))
178+
self.assertIsInstance(gmp, GMPv227)
179+
136180
def test_unknown_protocol(self):
137181
self.connection.read.return_value(
138182
b'<get_version_response status="200" status_text="OK">'

0 commit comments

Comments
 (0)