26973402aac5d216a66ae3fc8f2d7bcb0fd7ea89
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                    1) # SPDX-FileCopyrightText: 2024 Marco Ricci <m@the13thletter.info>
tests/test_sequin.py                    2) #
tests/test_sequin.py                    3) # SPDX-License-Identifier: MIT
tests/test_sequin.py                    4) 
tests/test_sequin.py                    5) """Test sequin.Sequin."""
tests/test_sequin.py                    6) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                    7) import collections
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                    8) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                    9) import pytest
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   10) 
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_sequin.py  11) from derivepassphrase import sequin
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                   12) 
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   13) 
Marco Ricci Add bitseq function in test...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   14) def bitseq(string: str) -> list[int]:
tests/test_sequin.py                   15)     """Convert a 0/1-string into a list of bits."""
tests/test_sequin.py                   16)     return [int(char, 2) for char in string]
tests/test_sequin.py                   17) 
tests/test_sequin.py                   18) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   19) class TestStaticFunctionality:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   20)     @pytest.mark.parametrize(
tests/test_sequin.py                   21)         ['sequence', 'base', 'expected'],
tests/test_sequin.py                   22)         [
tests/test_sequin.py                   23)             ([1, 2, 3, 4, 5, 6], 10, 123456),
tests/test_sequin.py                   24)             ([1, 2, 3, 4, 5, 6], 100, 10203040506),
tests/test_sequin.py                   25)             ([0, 0, 1, 4, 9, 7], 10, 1497),
tests/test_sequin.py                   26)             ([1, 0, 0, 1, 0, 0, 0, 0], 2, 144),
tests/test_sequin.py                   27)             ([1, 7, 5, 5], 8, 0o1755),
tests/test_sequin.py                   28)         ],
tests/test_sequin.py                   29)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   30)     def test_200_big_endian_number(
tests/test_sequin.py                   31)         self, sequence: list[int], base: int, expected: int
tests/test_sequin.py                   32)     ) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   33)         assert (
tests/test_sequin.py                   34)             sequin.Sequin._big_endian_number(sequence, base=base)
tests/test_sequin.py                   35)         ) == expected
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                   36) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   37)     @pytest.mark.parametrize(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   38)         ['exc_type', 'exc_pattern', 'sequence', 'base'],
tests/test_sequin.py                   39)         [
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   40)             (ValueError, 'invalid base 3 digit:', [-1], 3),
tests/test_sequin.py                   41)             (ValueError, 'invalid base:', [0], 1),
tests/test_sequin.py                   42)             (TypeError, 'not an integer:', [0.0, 1.0, 0.0, 1.0], 2),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   43)         ],
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   44)     )
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   45)     def test_300_big_endian_number_exceptions(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   46)         self,
tests/test_sequin.py                   47)         exc_type: type[Exception],
tests/test_sequin.py                   48)         exc_pattern: str,
tests/test_sequin.py                   49)         sequence: list[int],
tests/test_sequin.py                   50)         base: int,
tests/test_sequin.py                   51)     ) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   52)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_sequin.py                   53)             sequin.Sequin._big_endian_number(sequence, base=base)
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                   54) 
tests/test_sequin.py                   55) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   56) class TestSequin:
tests/test_sequin.py                   57)     @pytest.mark.parametrize(
tests/test_sequin.py                   58)         ['sequence', 'is_bitstring', 'expected'],
tests/test_sequin.py                   59)         [
tests/test_sequin.py                   60)             (
tests/test_sequin.py                   61)                 [1, 0, 0, 1, 0, 1],
tests/test_sequin.py                   62)                 False,
Marco Ricci Add bitseq function in test...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   63)                 bitseq('000000010000000000000000000000010000000000000001'),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   64)             ),
tests/test_sequin.py                   65)             ([1, 0, 0, 1, 0, 1], True, [1, 0, 0, 1, 0, 1]),
Marco Ricci Add bitseq function in test...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   66)             (b'OK', False, bitseq('0100111101001011')),
tests/test_sequin.py                   67)             ('OK', False, bitseq('0100111101001011')),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   68)         ],
tests/test_sequin.py                   69)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   70)     def test_200_constructor(
tests/test_sequin.py                   71)         self,
tests/test_sequin.py                   72)         sequence: str | bytes | bytearray | list[int],
tests/test_sequin.py                   73)         is_bitstring: bool,
tests/test_sequin.py                   74)         expected: list[int],
tests/test_sequin.py                   75)     ) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   76)         seq = sequin.Sequin(sequence, is_bitstring=is_bitstring)
tests/test_sequin.py                   77)         assert seq.bases == {2: collections.deque(expected)}
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                   78) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   79)     def test_201_generating(self) -> None:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   80)         seq = sequin.Sequin(
tests/test_sequin.py                   81)             [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1], is_bitstring=True
tests/test_sequin.py                   82)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   83)         assert seq.generate(1) == 0
tests/test_sequin.py                   84)         assert seq.generate(5) == 3
tests/test_sequin.py                   85)         assert seq.generate(5) == 3
tests/test_sequin.py                   86)         assert seq.generate(5) == 1
Marco Ricci Rename SequinExhaustedExcep...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   87)         with pytest.raises(sequin.SequinExhaustedError):
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   88)             seq.generate(5)
Marco Ricci Rename SequinExhaustedExcep...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   89)         with pytest.raises(sequin.SequinExhaustedError):
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   90)             seq.generate(1)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   91)         seq = sequin.Sequin(
tests/test_sequin.py                   92)             [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1], is_bitstring=True
tests/test_sequin.py                   93)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                   94)         with pytest.raises(ValueError, match='invalid target range'):
tests/test_sequin.py                   95)             seq.generate(0)
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                   96) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                   97)     def test_210_internal_generating(self) -> None:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                   98)         seq = sequin.Sequin(
tests/test_sequin.py                   99)             [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1], is_bitstring=True
tests/test_sequin.py                  100)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  101)         assert seq._generate_inner(5) == 3
tests/test_sequin.py                  102)         assert seq._generate_inner(5) == 3
tests/test_sequin.py                  103)         assert seq._generate_inner(5) == 1
tests/test_sequin.py                  104)         assert seq._generate_inner(5) == 5
tests/test_sequin.py                  105)         assert seq._generate_inner(1) == 0
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                  106)         seq = sequin.Sequin(
tests/test_sequin.py                  107)             [1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1], is_bitstring=True
tests/test_sequin.py                  108)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  109)         assert seq._generate_inner(1) == 0
tests/test_sequin.py                  110)         with pytest.raises(ValueError, match='invalid target range'):
tests/test_sequin.py                  111)             seq._generate_inner(0)
tests/test_sequin.py                  112)         with pytest.raises(ValueError, match='invalid base:'):
tests/test_sequin.py                  113)             seq._generate_inner(16, base=1)
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                  114) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                  115)     def test_211_shifting(self) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  116)         seq = sequin.Sequin([1, 0, 1, 0, 0, 1, 0, 0, 0, 1], is_bitstring=True)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                  117)         assert seq.bases == {
tests/test_sequin.py                  118)             2: collections.deque([1, 0, 1, 0, 0, 1, 0, 0, 0, 1])
tests/test_sequin.py                  119)         }
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_sequin.py                  120) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  121)         assert seq._all_or_nothing_shift(3) == (1, 0, 1)
tests/test_sequin.py                  122)         assert seq._all_or_nothing_shift(3) == (0, 0, 1)
tests/test_sequin.py                  123)         assert seq.bases[2] == collections.deque([0, 0, 0, 1])
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_sequin.py                  124) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  125)         assert seq._all_or_nothing_shift(5) == ()
tests/test_sequin.py                  126)         assert seq.bases[2] == collections.deque([0, 0, 0, 1])
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_sequin.py                  127) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  128)         assert seq._all_or_nothing_shift(4), (0, 0, 0, 1)
tests/test_sequin.py                  129)         assert 2 not in seq.bases
Marco Ricci Add unit tests, both new an...

Marco Ricci authored 5 months ago

tests/test_sequin.py                  130) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  131)     @pytest.mark.parametrize(
tests/test_sequin.py                  132)         ['sequence', 'is_bitstring', 'exc_type', 'exc_pattern'],
tests/test_sequin.py                  133)         [
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                  134)             (
tests/test_sequin.py                  135)                 [0, 1, 2, 3, 4, 5, 6, 7],
tests/test_sequin.py                  136)                 True,
tests/test_sequin.py                  137)                 ValueError,
tests/test_sequin.py                  138)                 'sequence item out of range',
tests/test_sequin.py                  139)             ),
tests/test_sequin.py                  140)             ('こんにちは。', False, ValueError, 'sequence item out of range'),
tests/test_sequin.py                  141)         ],
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_sequin.py                  142)     )
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_sequin.py                  143)     def test_300_constructor_exceptions(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_sequin.py                  144)         self,
tests/test_sequin.py                  145)         sequence: list[int] | str,
tests/test_sequin.py                  146)         is_bitstring: bool,
tests/test_sequin.py                  147)         exc_type: type[Exception],
tests/test_sequin.py                  148)         exc_pattern: str,
tests/test_sequin.py                  149)     ) -> None: