mirror of
https://github.com/JoelBender/bacpypes
synced 2025-10-05 22:18:16 +08:00
adjust the tests to expect the InvalidTag exception
This commit is contained in:
parent
3c3ad2fe7f
commit
60cba9c949
|
@ -9,6 +9,8 @@ Test Primitive Bit String
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import BitString, Tag
|
||||
|
||||
# some debugging
|
||||
|
@ -130,15 +132,15 @@ class TestBitString(unittest.TestCase):
|
|||
assert obj.value == [0, 0, 0, 0, 0, 0, 1]
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
BitString(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
BitString(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
BitString(tag)
|
||||
|
||||
def test_bit_string_copy(self):
|
||||
|
|
|
@ -9,6 +9,8 @@ Test Primitive Data Boolean
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Boolean, Tag
|
||||
|
||||
# some debugging
|
||||
|
@ -98,15 +100,15 @@ class TestBoolean(unittest.TestCase):
|
|||
assert obj.value == 1
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.integerAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Boolean(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Boolean(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Boolean(tag)
|
||||
|
||||
def test_boolean_copy(self):
|
||||
|
|
|
@ -9,7 +9,9 @@ Test Primitive Data Character String
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import CharacterString, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import CharacterString, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -98,15 +100,15 @@ class TestCharacterString(unittest.TestCase):
|
|||
assert obj.value == ''
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
CharacterString(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
CharacterString(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
CharacterString(tag)
|
||||
|
||||
def test_character_string_copy(self):
|
||||
|
@ -119,8 +121,8 @@ class TestCharacterString(unittest.TestCase):
|
|||
def test_character_string_endec(self):
|
||||
if _debug: TestCharacterString._debug("test_character_string_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = CharacterString(character_string_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = CharacterString(character_string_tag(''))
|
||||
|
||||
character_string_endec("", '00')
|
||||
character_string_endec("abc", '00616263')
|
||||
|
|
|
@ -9,6 +9,8 @@ Test Primitive Data Date
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Date, Tag
|
||||
|
||||
# some debugging
|
||||
|
@ -96,15 +98,15 @@ class TestDate(unittest.TestCase):
|
|||
assert obj.value == (1, 2, 3, 4)
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Date(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Date(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Date(tag)
|
||||
|
||||
def test_date_copy(self):
|
||||
|
@ -118,8 +120,8 @@ class TestDate(unittest.TestCase):
|
|||
def test_date_endec(self):
|
||||
if _debug: TestInteger._debug("test_date_endec")
|
||||
|
||||
# with self.assertRaises(IndexError):
|
||||
# obj = Date(date_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Date(date_tag(''))
|
||||
|
||||
def old_tests(self):
|
||||
self.test_values = [
|
||||
|
|
|
@ -11,7 +11,9 @@ import struct
|
|||
import math
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import Double, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Double, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -105,15 +107,15 @@ class TestDouble(unittest.TestCase):
|
|||
assert obj.value == 1.0
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Double(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Double(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Double(tag)
|
||||
|
||||
def test_double_copy(self):
|
||||
|
@ -126,8 +128,8 @@ class TestDouble(unittest.TestCase):
|
|||
def test_double_endec(self):
|
||||
if _debug: TestDouble._debug("test_double_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = Double(double_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Double(double_tag(''))
|
||||
|
||||
double_endec(0, '0000000000000000')
|
||||
double_endec(1, '3ff0000000000000')
|
||||
|
|
|
@ -9,7 +9,9 @@ Test Primitive Data Enumerated
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import Enumerated, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Enumerated, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -98,15 +100,15 @@ class TestEnumerated(unittest.TestCase):
|
|||
assert obj.value == 1
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Enumerated(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Enumerated(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Enumerated(tag)
|
||||
|
||||
def test_enumerated_copy(self):
|
||||
|
@ -119,8 +121,8 @@ class TestEnumerated(unittest.TestCase):
|
|||
def test_enumerated_endec(self):
|
||||
if _debug: TestEnumerated._debug("test_enumerated_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = Enumerated(enumerated_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Enumerated(enumerated_tag(''))
|
||||
|
||||
enumerated_endec(0, '00')
|
||||
enumerated_endec(1, '01')
|
||||
|
|
|
@ -9,7 +9,9 @@ Test Primitive Data Integer
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import Integer, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Integer, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -99,15 +101,15 @@ class TestInteger(unittest.TestCase):
|
|||
assert obj.value == 1
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Integer(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Integer(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Integer(tag)
|
||||
|
||||
def test_integer_copy(self):
|
||||
|
@ -120,8 +122,8 @@ class TestInteger(unittest.TestCase):
|
|||
def test_integer_endec(self):
|
||||
if _debug: TestInteger._debug("test_integer_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = Integer(integer_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Integer(integer_tag(''))
|
||||
|
||||
integer_endec(0, '00')
|
||||
integer_endec(1, '01')
|
||||
|
|
|
@ -9,7 +9,9 @@ Test Primitive Data Object Identifier
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import ObjectIdentifier, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import ObjectIdentifier, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -100,15 +102,15 @@ class TestObjectIdentifier(unittest.TestCase):
|
|||
assert obj.value == ('pulseConverter', 3)
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectIdentifier(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectIdentifier(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectIdentifier(tag)
|
||||
|
||||
def test_object_identifier_copy(self):
|
||||
|
@ -121,9 +123,8 @@ class TestObjectIdentifier(unittest.TestCase):
|
|||
def test_object_identifier_endec(self):
|
||||
if _debug: TestObjectIdentifier._debug("test_object_identifier_endec")
|
||||
|
||||
### this should raise a DecodingError
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = ObjectIdentifier(object_identifier_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = ObjectIdentifier(object_identifier_tag(''))
|
||||
|
||||
# test standard types
|
||||
object_identifier_endec(('analogInput', 0), '00000000')
|
||||
|
|
|
@ -9,8 +9,9 @@ Test Primitive Data ObjectType
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import ObjectType, Tag, DecodingError, \
|
||||
expand_enumerations
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import ObjectType, Tag, expand_enumerations
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -143,15 +144,15 @@ class TestObjectType(unittest.TestCase):
|
|||
assert obj.value == 'analogOutput'
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectType(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectType(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
ObjectType(tag)
|
||||
|
||||
def test_object_type_copy(self):
|
||||
|
@ -165,8 +166,8 @@ class TestObjectType(unittest.TestCase):
|
|||
def test_object_type_endec(self):
|
||||
if _debug: TestObjectType._debug("test_object_type_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = ObjectType(object_type_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = ObjectType(object_type_tag(''))
|
||||
|
||||
object_type_endec('analogInput', '00')
|
||||
object_type_endec('analogOutput', '01')
|
||||
|
|
|
@ -10,6 +10,8 @@ import unittest
|
|||
import struct
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import OctetString, Tag
|
||||
|
||||
# some debugging
|
||||
|
@ -98,15 +100,15 @@ class TestOctetString(unittest.TestCase):
|
|||
assert obj.value == xtob('00')
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
OctetString(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
OctetString(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
OctetString(tag)
|
||||
|
||||
def test_octet_string_copy(self):
|
||||
|
|
|
@ -11,7 +11,9 @@ import struct
|
|||
import math
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import Real, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Real, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -106,15 +108,15 @@ class TestReal(unittest.TestCase):
|
|||
assert obj.value == 1.0
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Real(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Real(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Real(tag)
|
||||
|
||||
def test_real_copy(self):
|
||||
|
@ -127,8 +129,8 @@ class TestReal(unittest.TestCase):
|
|||
def test_real_endec(self):
|
||||
if _debug: TestReal._debug("test_real_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = Real(real_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Real(real_tag(''))
|
||||
|
||||
real_endec(0, '00000000')
|
||||
real_endec(1, '3f800000')
|
||||
|
|
|
@ -9,6 +9,8 @@ Test Primitive Data Time
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Time, Tag
|
||||
|
||||
# some debugging
|
||||
|
@ -103,15 +105,15 @@ class TestTime(unittest.TestCase):
|
|||
assert obj.value == (1, 2, 3, 4)
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Time(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Time(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Time(tag)
|
||||
|
||||
def test_time_copy(self):
|
||||
|
@ -131,9 +133,8 @@ class TestTime(unittest.TestCase):
|
|||
def test_time_endec(self):
|
||||
if _debug: TestTime._debug("test_time_endec")
|
||||
|
||||
### this should raise a decoding error
|
||||
# with self.assertRaises(IndexError):
|
||||
# obj = Time(time_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Time(time_tag(''))
|
||||
|
||||
time_endec((0, 0, 0, 0), '00000000')
|
||||
time_endec((1, 0, 0, 0), '01000000')
|
||||
|
|
|
@ -9,7 +9,9 @@ Test Primitive Data Unsigned
|
|||
import unittest
|
||||
|
||||
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
|
||||
from bacpypes.primitivedata import Unsigned, Tag, DecodingError
|
||||
|
||||
from bacpypes.errors import InvalidTag
|
||||
from bacpypes.primitivedata import Unsigned, Tag
|
||||
|
||||
# some debugging
|
||||
_debug = 0
|
||||
|
@ -98,15 +100,15 @@ class TestUnsigned(unittest.TestCase):
|
|||
assert obj.value == 1
|
||||
|
||||
tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Unsigned(tag)
|
||||
|
||||
tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Unsigned(tag)
|
||||
|
||||
tag = Tag(Tag.openingTagClass, 0)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(InvalidTag):
|
||||
Unsigned(tag)
|
||||
|
||||
def test_unsigned_copy(self):
|
||||
|
@ -119,8 +121,8 @@ class TestUnsigned(unittest.TestCase):
|
|||
def test_unsigned_endec(self):
|
||||
if _debug: TestUnsigned._debug("test_unsigned_endec")
|
||||
|
||||
# with self.assertRaises(DecodingError):
|
||||
# obj = Unsigned(unsigned_tag(''))
|
||||
with self.assertRaises(InvalidTag):
|
||||
obj = Unsigned(unsigned_tag(''))
|
||||
|
||||
unsigned_endec(0, '00')
|
||||
unsigned_endec(1, '01')
|
||||
|
|
Loading…
Reference in New Issue
Block a user