Пример #1
0
    def test_reset(self):
        rotor = emul.Rotor(string.ascii_uppercase, [])
        rotor.ring_pos = 7
        rotor.position = 3
        rotor.just_turned_over = True

        rotor.reset()
        assert rotor.ring_pos == rotor.position == 0
        assert not rotor.just_turned_over
Пример #2
0
 def test_init_can_set_thin_true(self):
     rotor = emul.Rotor(string.ascii_uppercase, [], thin=True)
     assert rotor.thin
Пример #3
0
 def test_init_normalizes_turnover_case(self):
     rotor = emul.Rotor(string.ascii_uppercase, 'aBCdeF')
     assert rotor.turnovers == [0, 1, 2, 3, 4, 5]
Пример #4
0
 def test_init_defaults_thin_false(self):
     rotor = emul.Rotor(string.ascii_uppercase, [])
     assert not rotor.thin
Пример #5
0
 def test_init_sets_turnovers_correctly_str_len3(self):
     rotor = emul.Rotor(string.ascii_uppercase, 'ABC')
     assert rotor.turnovers == [0, 1, 2]
Пример #6
0
 def test_init_sets_turnovers_correctly_list(self):
     rotor = emul.Rotor(string.ascii_uppercase, ['A', 'B', 'C'])
     assert rotor.turnovers == [0, 1, 2]
Пример #7
0
 def test_init_allows_empty_turnover(self):
     rotor = emul.Rotor(string.ascii_uppercase, [])
     assert rotor.turnovers == []
Пример #8
0
 def test_init_rejects_improper_turnover_list(self):
     with pytest.raises(ValueError):
         emul.Rotor(string.ascii_uppercase, ['AB', 'CD'])
Пример #9
0
 def test_init_normalizes_cipher_case(self):
     rotor = emul.Rotor('ABcdEfGhIjklMnoPQRstuVWxyZ', [])
     assert rotor.cipher == list(string.ascii_uppercase)
Пример #10
0
 def test_init_rejects_mixed_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('@BCD3FG#!JKLMNOPQR$TUVWXYZ', [])
Пример #11
0
 def test_init_rejects_nonalphabetical_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('1234567890!@#$%^&*()_-+=[]', [])
Пример #12
0
 def test_init_rejects_short_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('ABC', [])
Пример #13
0
 def test_init_rejects_long_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor(string.ascii_uppercase * 2, [])