Exemplo n.º 1
0
 def testShorthandForm(self):
     panel_client._validate_controls([{
         'id':
         'Froomulator',
         'state':
         '0',
         'actions': [['0', '1', '2'], 'Set Froomulator to %s!']
     }])
Exemplo n.º 2
0
 def testRequireControlKeys(self):
     with self.assertRaisesRegexp(Exception, '`state` is missing'):
         panel_client._validate_controls([{
             'id': 'defenestrator',
             'actions': {
                 '0': '',
                 '1': 'Defenestrate the aristocracy!'
             }
         }])
Exemplo n.º 3
0
 def testLonghandForm(self):
     panel_client._validate_controls([{
         'id': 'defenestrator',
         'state': '0',
         'actions': {
             '0': '',
             '1': 'Defenestrate the aristocracy!'
         }
     }])
Exemplo n.º 4
0
 def testStatesDontHaveToBeNumeric(self):
     panel_client._validate_controls([{
         'id': 'octo',
         'state': 'nothing',
         'actions': {
             'nothing': '',
             'nipple': 'Octo bite raven girl nipple!',
             'mouth': 'Octo kiss raven girl mouth!'
         }
     }])
Exemplo n.º 5
0
 def testIgnoreUnknownControlKeys(self):
     panel_client._validate_controls([{
         'id': 'defenestrator',
         'state': '0',
         'actions': {
             '0': '',
             '1': 'Defenestrate the aristocracy!'
         },
         'type': 'button'
     }])
Exemplo n.º 6
0
 def formatStringRequiredInShorthandForm(self):
     with self.assertRaisesRegexp(Exception,
                                  'Shorthand `actions` is malformed'):
         panel_client._validate_controls([{
             'id':
             'Froomulator',
             'state':
             '0',
             'actions': [['0', '1', '2'], 'Set Froomulator!']
         }])
Exemplo n.º 7
0
 def formatStringsOnlySupportedInShorthandForm(self):
     with self.assertRaisesRegexp(
             Exception,
             'Format strings are only supported in the shorthand form of `actions`'
     ):
         panel_client._validate_controls([{
             'id': 'defenestrator',
             'state': '0',
             'actions': {
                 '0': '',
                 '1': 'Defenestrate %s!'
             }
         }])
Exemplo n.º 8
0
 def testIdsMustBeUnique(self):
     with self.assertRaisesRegexp(Exception, 'Control ids are not unique'):
         panel_client._validate_controls([{
             'id': 'defenestrator',
             'state': '0',
             'actions': {
                 '0': '',
                 '1': 'Defenestrate the aristocracy!'
             }
         }, {
             'id': 'defenestrator',
             'state': '0',
             'actions': {
                 '0': '',
                 '1': 'Defenestrate the aristocracy!'
             }
         }])
Exemplo n.º 9
0
    def testStateMustBeString(self):
        with self.assertRaisesRegexp(Exception, '`state` is not a string'):
            panel_client._validate_controls([{
                'id': 'defenestrator',
                'state': 0,
                'actions': {
                    0: '',
                    1: 'Defenestrate the aristocracy!'
                }
            }])

        with self.assertRaisesRegexp(Exception,
                                     'State in `actions` is not a string'):
            panel_client._validate_controls([{
                'id': 'defenestrator',
                'state': '0',
                'actions': {
                    '0': '',
                    1: 'Defenestrate the aristocracy!'
                }
            }])

        with self.assertRaisesRegexp(Exception,
                                     'State in `actions` is not a string'):
            panel_client._validate_controls([{
                'id':
                'Froomulator',
                'state':
                '0',
                'actions': [['0', 1], 'Set Froomulator to %s!']
            }])
Exemplo n.º 10
0
    def testStateMustBeInActions(self):
        with self.assertRaisesRegexp(Exception,
                                     '`state` not present in `actions`'):
            panel_client._validate_controls([{
                'id': 'defenestrator',
                'state': '2',
                'actions': {
                    '0': '',
                    '1': 'Defenestrate the aristocracy!'
                },
                'type': 'button'
            }])

        with self.assertRaisesRegexp(Exception,
                                     '`state` not present in `actions`'):
            panel_client._validate_controls([{
                'id':
                'Froomulator',
                'state':
                '3',
                'actions': [['0', '1', '2'], 'Set Froomulator to %s!']
            }])