def _translate_build_active_request(self, active, expected):
     '''
     Translate a build active request.
     :param active: True if any builds active, false otherwise
     :param expected: on if True, off otherwise
     '''
     command = parser.translate(requests.BuildActiveRequest(active))
     self.assertEqual('yellow={0}\n'.format(expected), command)
    def test_translate_status_request_is_down(self):
        '''
        Can only translate a server down request.
        '''
        request = requests.StatusRequest(False)
        command = parser.translate(request)

        # Split correctly generates an empty string after the last \n
        expected = ['red=on', 'green=on', 'yellow=on', '']
        self.assertTrue(command.count('\n'), 3)
        self.assertListEqual(expected, command.split('\n'))
 def _translate_attention_request(self, attention, priority):
     '''
     Translate a build active request.
     :param attention: True if attention required, false otherwise
     :param priority: True if attention is priority, off otherwise
     '''
     command = parser.translate(requests.AttentionRequest(attention,
                                                          priority))
     command_split = command.split('\n')
     self.assertEquals(command.count('\n'), 2)
     if attention and priority:
         expected = ['red=sos', 'green=off', '']
         self.assertListEqual(expected, command_split)
     elif attention and not priority:
         expected = ['red=on', 'green=off', '']
         self.assertListEqual(expected, command_split)
     elif not attention and not priority:
         expected = ['red=off', 'green=on', '']
         self.assertListEqual(expected, command_split)
     else:
         self.fail('Invalid')