Пример #1
0
    def _find_attribute_changes(self, orginal, new):
        attribute_json = orginal['attributes']
        new = new['attributes']

        allowable = {category for category in attribute_json if attribute_json[category]['controllable']}
        categories_changed = self._report_keys_changed(attribute_json, new, allowable)

        changes = []

        for category in categories_changed:
            self._report_keys_changed(attribute_json[category], new[category], {'current'})
            current_state = new[category]['current']

            current_state = verify_state(attribute_json[category], current_state)
            if current_state is not None:
                changes.append((category, current_state))
            else:
                raise HTTPError(422, "Current was not a possible state.")

        return changes
Пример #2
0
 def test_possible_rep(self):
    ser = self.attributes['huh'].serializable()
    ascii_str = attributes.verify_state(ser, 'NOPE')
    self.assertEquals(ascii_str, b'NOPE')
    ascii_str = attributes.verify_state(ser, 'NOPE                                        ')
    self.assertEquals(ascii_str, None)