diff options
Diffstat (limited to 'tests/test_binds.py')
-rw-r--r-- | tests/test_binds.py | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/tests/test_binds.py b/tests/test_binds.py index e1fac43..713ef08 100644 --- a/tests/test_binds.py +++ b/tests/test_binds.py @@ -3,16 +3,19 @@ # Copyright (C) 2021 Thomas Touhey <thomas@touhey.fr> # This file is part of the pyfingerd project, which is MIT-licensed. # ***************************************************************************** -""" Tests for the pyfingerd server. """ +"""Tests for the pyfingerd server.""" import socket -from pyfingerd.binds import FingerBindsDecoder, FingerTCPv4Bind +from pyfingerd.binds import ( + FingerBindsDecoder, FingerTCPv4Bind, FingerTCPv6Bind, +) + import pytest class TestFingerDecoder: - """ Test binds. """ + """Test binds.""" @pytest.fixture def decoder(self): @@ -22,16 +25,41 @@ class TestFingerDecoder: assert decoder.decode('') == () @pytest.mark.parametrize('raw,cls,params', ( - ('127.0.0.1:79', FingerTCPv4Bind, ( - socket.AF_INET, - '127.0.0.1', - 79, - )), - ('127.0.2.3', FingerTCPv4Bind, ( - socket.AF_INET, + ( + '127.0.0.1:79', + FingerTCPv4Bind, + (socket.AF_INET, '127.0.0.1', 79), + ), + ( '127.0.2.3', - 79, - )), + FingerTCPv4Bind, + (socket.AF_INET, '127.0.2.3', 79), + ), + ( + '1.2:1234', + FingerTCPv4Bind, + (socket.AF_INET, '1.0.0.2', 1234), + ), + ( + '1.257:1235', + FingerTCPv4Bind, + (socket.AF_INET, '1.0.1.1', 1235), + ), + ( + '[::1]', + FingerTCPv6Bind, + (socket.AF_INET6, '::1', 79), + ), + ( + '[1::2:3]:8081', + FingerTCPv6Bind, + (socket.AF_INET6, '1::2:3', 8081), + ), + ( + '[1:2::3.4.5.6]:8246', + FingerTCPv6Bind, + (socket.AF_INET6, '1:2::304:506', 8246), + ), )) def test_binds(self, decoder, raw, cls, params): binds = decoder.decode(raw) |