Skip to content

Commit

Permalink
Merge 3ace7e4 into 6b5495c
Browse files Browse the repository at this point in the history
  • Loading branch information
jlusiardi committed Jul 14, 2019
2 parents 6b5495c + 3ace7e4 commit 28bd00d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
5 changes: 3 additions & 2 deletions homekit/model/feature_flags.py
Expand Up @@ -27,8 +27,9 @@ def __init__(self):
}

def __getitem__(self, item):
if item in self._data:
return self._data[item]
bit_value = item & 0x01
if bit_value in self._data:
return self._data[bit_value]

raise KeyError('Item {item} not found'.format(item=item))

Expand Down
35 changes: 35 additions & 0 deletions tests/feature_flags_test.py
@@ -0,0 +1,35 @@
#
# Copyright 2018 Joachim Lusiardi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import unittest

from homekit.model.feature_flags import FeatureFlags


class TestFeatureFlags(unittest.TestCase):

def test_no_support_hap_pairing(self):
self.assertEqual(FeatureFlags[0], 'No support for HAP Pairing')

def test_support_hap_pairing(self):
self.assertEqual(FeatureFlags[1], 'Supports HAP Pairing')

def test_bug_143(self):
# 0b10 -> 2 means no hap pairing support?
self.assertEqual(FeatureFlags[2], 'No support for HAP Pairing')

# def test_unknown_code(self):
# self.assertRaises(KeyError, FeatureFlags.__getitem__, 99)

0 comments on commit 28bd00d

Please sign in to comment.