def _get_attrs(self): """Return attributes.""" url = API_URI + DEVICES_ENDPOINT try: if self.family == 'doorbots' and self.shared: lst = self._ring.query(url).get('authorized_doorbots') else: lst = self._ring.query(url).get(self.family) index = _locator(lst, 'description', self.name) if index == NOT_FOUND: return None except AttributeError: return None self._attrs = lst[index] return True
def test_locator(self): """Test _locator method.""" self.assertEquals(-1, _locator([DATA], 'key', 'bar')) self.assertEquals(0, _locator([DATA], 'key', 'value'))