Example #1
0
 def test_errors(self):
      with self.assertRaises(Exception):
          commands(-1)
      with self.assertRaises(Exception):
          commands('foo')
      with self.assertRaises(Exception):
          commands(1.1)
Example #2
0
 def test_jump_for_1000(self):
     self.assertEqual(commands(8), ["jump"])
Example #3
0
 def test_close_your_eyes_for_100(self):
     self.assertEqual(commands(4), ["close your eyes"])
Example #4
0
 def test_double_blink_for_10(self):
     self.assertEqual(commands(2), ["double blink"])
Example #5
0
 def test_all_possible_actions(self):
     exp = ["wink", "double blink", "close your eyes", "jump"]
     for c in (15, 47):
         self.assertEqual(commands(15), exp)
Example #6
0
 def test_do_nothing_for_zero(self):
     self.assertEqual(commands(0), [])
Example #7
0
 def test_all_possible_actions(self):
     self.assertEqual(commands(15),
                      ["wink", "double blink", "close your eyes", "jump"])
Example #8
0
 def test_reversing_one_action_gives_the_same_action(self):
     self.assertEqual(commands(24), ["jump"])
Example #9
0
 def test_reverse_all_possible_actions(self):
     self.assertEqual(commands(31),
                      ['jump', 'close your eyes', 'double blink', 'wink'])
Example #10
0
 def test_all_possible_actions(self):
     self.assertEqual(commands(15),
                      ['wink', 'double blink', 'close your eyes', 'jump'])
Example #11
0
 def test_reverse_two_actions(self):
     self.assertEqual(commands(19), ['double blink', 'wink'])
Example #12
0
 def test_combine_two_actions(self):
     self.assertEqual(commands(3), ['wink', 'double blink'])
Example #13
0
 def test_reverse_all_possible_actions(self):
     exp = ["jump", "close your eyes", "double blink", "wink"]
     for c in [31, 63]:
         self.assertEqual(commands(31), exp)
Example #14
0
 def test_combine_two_actions(self):
     self.assertEqual(commands(3), ["wink", "double blink"])
Example #15
0
 def test_reversible1(self):
     self.assertEqual(secret_code(commands(27)), 27)
Example #16
0
 def test_reverse_two_actions(self):
     self.assertEqual(commands(19), ["double blink", "wink"])
Example #17
0
 def test_reversible2(self):
     self.assertEqual(secret_code(commands(1)), 1)
Example #18
0
 def test_reversing_no_actions_still_gives_no_actions(self):
     self.assertEqual(commands(16), [])
Example #19
0
 def test_reversible3(self):
     self.assertEqual(secret_code(commands(7)), 7)
Example #20
0
 def test_reverse_all_possible_actions(self):
     self.assertEqual(commands(31),
                      ["jump", "close your eyes", "double blink", "wink"])
Example #21
0
 def test_reversible4(self):
     inp = ['wink', 'double blink', 'jump']
     self.assertEqual(commands(secret_code(inp)), inp)
Example #22
0
 def test_wink_for_1(self):
     self.assertEqual(commands(1), ["wink"])
Example #23
0
 def test_reversing_no_actions_still_gives_no_actions(self):
     for c in [16, 32, 64, 128, 256]:
         self.assertEqual(commands(c), [])