From 46f9b19fbf99b61b7df0543baa635cfd3c2b99d9 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Mon, 24 Aug 2015 13:39:11 -0400 Subject: [PATCH] make it a little easier to create application encoded integer tags --- tests/test_primitive_data/test_tag.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/test_primitive_data/test_tag.py b/tests/test_primitive_data/test_tag.py index 95ff20f..3ba62c6 100644 --- a/tests/test_primitive_data/test_tag.py +++ b/tests/test_primitive_data/test_tag.py @@ -16,8 +16,6 @@ from bacpypes.primitivedata import Tag, ApplicationTag, ContextTag, \ DecodingError from bacpypes.pdu import PDUData -from test_integer import integer_tag -from test_unsigned import unsigned_tag # some debugging _debug = 0 @@ -29,6 +27,16 @@ def tag_tuple(tag): return (tag.tagClass, tag.tagNumber, tag.tagLVT, tag.tagData) +@bacpypes_debugging +def IntegerTag(v): + """Return an application encoded integer tag with the appropriate value. + """ + obj = Integer(v) + tag = Tag() + obj.encode(tag) + return tag + + @bacpypes_debugging def obj_decode(blob): """Build PDU from the string, decode the tag, convert to an object.""" @@ -472,7 +480,7 @@ class TestTagList(unittest.TestCase): def test_peek(self): if _debug: TestTagList._debug("test_peek") - tag0 = integer_tag('00') + tag0 = IntegerTag(0) taglist = TagList([tag0]) # peek at the first tag @@ -495,9 +503,9 @@ class TestTagList(unittest.TestCase): ContextTag(0, xtob('00')), ContextTag(1, xtob('01')), OpeningTag(2), - integer_tag('03'), + IntegerTag(3), OpeningTag(0), - integer_tag('04'), + IntegerTag(4), ClosingTag(0), ClosingTag(2), ] @@ -538,8 +546,8 @@ class TestTagList(unittest.TestCase): """ if _debug: TestTagList._debug("test_endec_1") - tag0 = integer_tag('00') - tag1 = integer_tag('01') + tag0 = IntegerTag(0x00) + tag1 = IntegerTag(0x01) taglist = TagList([tag0, tag1]) data = PDUData() @@ -572,7 +580,7 @@ class TestTagList(unittest.TestCase): if _debug: TestTagList._debug("test_endec_2") tag0 = OpeningTag(0) - tag1 = integer_tag('0102') + tag1 = IntegerTag(0x0102) tag2 = ClosingTag(0) taglist = TagList([tag0, tag1, tag2])