def test_custom_alphabet(self): rotor = Rotor( "Test", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", "A4", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") rotor.set_position('z') rotor.rotate() self.assertEqual(rotor.get_position(), "A") self.assertTrue(rotor.is_on_notch())
def test_multiple_notches(self): notches = "ZABT" rotor = Rotor("Test", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", notches) rotor.set_position('A') for i in range(ord("A"), ord("Z") + 1): should_be_on_position = chr(i) should_be_on_notch = should_be_on_position in notches self.assertEqual(rotor.get_position(), should_be_on_position) self.assertEqual(rotor.is_on_notch(), should_be_on_notch) rotor.rotate() self.assertEqual(rotor.get_position(), "A")