Fix: attribute vendor codes retrieval
This commit is contained in:
@@ -454,7 +454,7 @@ class Dictionary:
|
|||||||
self.cur_vendor.attrs[attrcode] = attribute
|
self.cur_vendor.attrs[attrcode] = attribute
|
||||||
|
|
||||||
if self.cur_vendor != self.rfc_vendor:
|
if self.cur_vendor != self.rfc_vendor:
|
||||||
codes = [26] + codes
|
codes = [26, self.cur_vendor.code] + codes
|
||||||
attrcode = codes[0] if len(codes) == 1 else tuple(codes)
|
attrcode = codes[0] if len(codes) == 1 else tuple(codes)
|
||||||
self.attrindex[attrcode] = attribute
|
self.attrindex[attrcode] = attribute
|
||||||
self.attrindex[name] = attribute
|
self.attrindex[name] = attribute
|
||||||
|
|||||||
@@ -377,3 +377,34 @@ def test_invalid_attribute_flags(invalid_flag):
|
|||||||
dictionary = StringIO(f"ATTRIBUTE NAME 123 octets {invalid_flag}")
|
dictionary = StringIO(f"ATTRIBUTE NAME 123 octets {invalid_flag}")
|
||||||
with pytest.raises(ParseError):
|
with pytest.raises(ParseError):
|
||||||
Dictionary("", dictionary)
|
Dictionary("", dictionary)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"attribute", ["RFC-ATTRIBUTE", "VENDOR-ATTRIBUTE", 7, (26, 5555, 7)]
|
||||||
|
)
|
||||||
|
def test_get_attributes_from_dictionaries(attribute):
|
||||||
|
dictionary = StringIO(
|
||||||
|
"ATTRIBUTE RFC-ATTRIBUTE 7 integer\n"
|
||||||
|
"VENDOR TEST-VENDOR 5555\n"
|
||||||
|
"BEGIN-VENDOR TEST-VENDOR\n"
|
||||||
|
"ATTRIBUTE VENDOR-ATTRIBUTE 7 integer\n"
|
||||||
|
"END-VENDOR TEST-VENDOR"
|
||||||
|
)
|
||||||
|
dd = Dictionary("", dictionary)
|
||||||
|
_ = dd[attribute]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"attribute", ["RFC-ATTRIBUTE1", 8, (26, 5556, 7), (26, 5555, 8)]
|
||||||
|
)
|
||||||
|
def test_get_nonexisting_attributes_from_dictionaries(attribute):
|
||||||
|
dictionary = StringIO(
|
||||||
|
"ATTRIBUTE RFC-ATTRIBUTE 7 integer\n"
|
||||||
|
"VENDOR TEST-VENDOR 5555\n"
|
||||||
|
"BEGIN-VENDOR TEST-VENDOR\n"
|
||||||
|
"ATTRIBUTE VENDOR-ATTRIBUTE 7 integer\n"
|
||||||
|
"END-VENDOR TEST-VENDOR"
|
||||||
|
)
|
||||||
|
dd = Dictionary("", dictionary)
|
||||||
|
with pytest.raises(KeyError):
|
||||||
|
_ = dd[attribute]
|
||||||
|
|||||||
Reference in New Issue
Block a user