def is_valid_extra_spec(k, v): valid_extra_spec_key = is_valid_string(k) valid_type = is_valid_string(v) or isinstance(v, bool) valid_required_extra_spec = ( share_types.is_valid_required_extra_spec(k, v) in (None, True)) valid_optional_extra_spec = ( share_types.is_valid_optional_extra_spec(k, v) in (None, True)) return (valid_extra_spec_key and valid_type and valid_required_extra_spec and valid_optional_extra_spec)
def is_valid_extra_spec(k, v): valid_extra_spec_key = is_valid_string(k) valid_type = is_valid_string(v) or isinstance(v, bool) valid_required_extra_spec = ( share_types.is_valid_required_extra_spec(k, v) in (None, True)) valid_optional_extra_spec = ( share_types.is_valid_optional_extra_spec(k, v) in (None, True)) return (valid_extra_spec_key and valid_type and valid_required_extra_spec and valid_optional_extra_spec)
def test_is_valid_optional_extra_spec_valid_unknown_key(self): result = share_types.is_valid_optional_extra_spec('fake', 'fake') self.assertIsNone(result)
def test_is_valid_optional_extra_spec_valid(self, key, value): result = share_types.is_valid_optional_extra_spec(key, value) self.assertTrue(result)
def test_is_valid_optional_extra_spec_valid_unknown_key(self): result = share_types.is_valid_optional_extra_spec('fake', 'fake') self.assertIsNone(result)
def test_is_valid_optional_extra_spec_valid(self, key, value): result = share_types.is_valid_optional_extra_spec(key, value) self.assertTrue(result)