コード例 #1
0
 def test_multiple_default_confirmations(self):
     with self.assertRaises(InvalidConfig):
         get_confirmation('', {}, {
             'bar': {
                 'is_default': True
             },
             'foo': {
                 'is_default': True
             }
         })
コード例 #2
0
ファイル: listener.py プロジェクト: vagelim/amazon-dash
    def __init__(self, src, data=None, config=None):
        """

        :param str src: Mac address
        :param data: device data
        """
        data = data or {}
        config = config or {}

        if isinstance(src, Device):
            src = src.src
        self.src = src.lower()
        self.data = data
        execs = [
            cls(self.name, data) for name, cls in EXECUTE_CLS.items()
            if name in self.data
        ]
        if len(execs) > 1:
            raise InvalidConfig(
                extra_body=
                'There can only be one method of execution on a device. The device is {}. '
                .format(self.name))
        elif len(execs):
            self.execute_instance = execs[0]
            self.execute_instance.validate()
        self.confirmation = get_confirmation(src, data,
                                             config.get('confirmations', {}))
コード例 #3
0
 def test_default_confirmation(self):
     cls = get_confirmation(
         '', {}, {'foo': {
             'service': 'disabled',
             'is_default': True
         }})
     self.assertIsInstance(cls, DisabledConfirmation)
コード例 #4
0
 def test_valid_confirmation_name(self):
     cls = get_confirmation('', {'confirmation': 'foo'}, {'foo': {'service': 'disabled'}})
     self.assertIsInstance(cls, DisabledConfirmation)
コード例 #5
0
 def test_invalid_confirmation_name(self):
     with self.assertRaises(InvalidConfig):
         get_confirmation('', {'confirmation': 'foo'}, {'bar': {}})