示例#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, [])