/
test_BinaryInputObject.py
103 lines (96 loc) · 5.28 KB
/
test_BinaryInputObject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Nose Test Objects BinaryInputObject
---------------------
"""
import unittest
from helper import TestObjectHelper
from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob
from bacpypes.object import BinaryInputObject, WritableProperty, ReadableProperty, OptionalProperty
from bacpypes.primitivedata import BitString, Boolean, CharacterString, Date, Double, \
Enumerated, Integer, Null, ObjectIdentifier, OctetString, Real, Time, \
Unsigned
from bacpypes.constructeddata import AnyAtomic, Array, ArrayOf, Choice, Element, \
Sequence, SequenceOf
from bacpypes.basetypes import AccessCredentialDisable, AccessCredentialDisableReason, \
AccessEvent, AccessPassbackMode, AccessRule, AccessThreatLevel, \
AccessUserType, AccessZoneOccupancyState, AccumulatorRecord, Action, \
ActionList, AddressBinding, AssignedAccessRights, AuthenticationFactor, \
AuthenticationFactorFormat, AuthenticationPolicy, AuthenticationStatus, \
AuthorizationException, AuthorizationMode, BackupState, BinaryPV, \
COVSubscription, CalendarEntry, ChannelValue, ClientCOV, \
CredentialAuthenticationFactor, DailySchedule, DateRange, DateTime, \
Destination, DeviceObjectPropertyReference, DeviceObjectReference, \
DeviceStatus, DoorAlarmState, DoorSecuredStatus, DoorStatus, DoorValue, \
EngineeringUnits, EventNotificationSubscription, EventParameter, \
EventState, EventTransitionBits, EventType, FaultParameter, FaultType, \
FileAccessMethod, LifeSafetyMode, LifeSafetyOperation, LifeSafetyState, \
LightingCommand, LightingInProgress, LightingTransition, LimitEnable, \
LockStatus, LogMultipleRecord, LogRecord, LogStatus, LoggingType, \
Maintenance, NetworkSecurityPolicy, NodeType, NotifyType, \
ObjectPropertyReference, ObjectTypesSupported, OptionalCharacterString, \
Polarity, PortPermission, Prescale, PriorityArray, ProcessIdSelection, \
ProgramError, ProgramRequest, ProgramState, PropertyAccessResult, \
PropertyIdentifier, Recipient, Reliability, RestartReason, Scale, \
SecurityKeySet, SecurityLevel, Segmentation, ServicesSupported, \
SetpointReference, ShedLevel, ShedState, SilencedState, SpecialEvent, \
StatusFlags, TimeStamp, VTClass, VTSession, WriteStatus
from bacpypes.errors import ConfigurationError, ExecutionError
# some debugging
_debug = 1
_log = ModuleLogger(globals())
@bacpypes_debugging
class Test_BinaryInputObject(unittest.TestCase, TestObjectHelper):
"""
This test will verify that the object created has good number of properties
Will test that each property is correct datatype
Will test that only Writable property can be written
Will test that all properties can be read
"""
def setUp(self):
if _debug: Test_BinaryInputObject._debug("Test_BinaryInputObject")
self.obj = BinaryInputObject()
self.objType = 'binaryInput'
self.identifiers = self.build_list_of_identifiers(self.obj.properties)
self.numberOfPropertiesRequired = 28
self.writeValue = 1234
self.listOfProperties = \
[ (ReadableProperty,'presentValue', BinaryPV)
, (OptionalProperty,'deviceType', CharacterString)
, (ReadableProperty,'statusFlags', StatusFlags)
, (ReadableProperty,'eventState', EventState)
, (OptionalProperty,'reliability', Reliability)
, (ReadableProperty,'outOfService', Boolean)
, (ReadableProperty,'polarity', Polarity)
, (OptionalProperty,'inactiveText', CharacterString)
, (OptionalProperty,'activeText', CharacterString)
, (OptionalProperty,'changeOfStateTime', DateTime)
, (OptionalProperty,'changeOfStateCount', Unsigned)
, (OptionalProperty,'timeOfStateCountReset', DateTime)
, (OptionalProperty,'elapsedActiveTime', Unsigned)
, (OptionalProperty,'timeOfActiveTimeReset', DateTime)
, (OptionalProperty,'timeDelay', Unsigned)
, (OptionalProperty,'notificationClass', Unsigned)
, (OptionalProperty,'alarmValue', BinaryPV)
, (OptionalProperty,'eventEnable', EventTransitionBits)
, (OptionalProperty,'ackedTransitions', EventTransitionBits)
, (OptionalProperty,'notifyType', NotifyType)
, (OptionalProperty,'eventTimeStamps', ArrayOf(TimeStamp))
, (OptionalProperty,'eventMessageTexts', ArrayOf(CharacterString))
, (OptionalProperty,'eventMessageTextsConfig', ArrayOf(CharacterString))
, (OptionalProperty,'eventDetectionEnable', Boolean)
, (OptionalProperty,'eventAlgorithmInhibitRef', ObjectPropertyReference)
, (OptionalProperty,'eventAlgorithmInhibit', Boolean)
, (OptionalProperty,'timeDelayNormal', Unsigned)
, (OptionalProperty,'reliabilityEvaluationInhibit', Boolean)
]
def test_object(self):
self.object_type(self.obj,self.objType)
self.object_number_of_properties(self.obj,self.numberOfPropertiesRequired)
self.object_property_identifiers(self.obj)
self.object_property_dataType(self.obj)
self.object_noWritingToReadableProperty(self.obj,self.writeValue)
self.object_can_write_to_writableProperty(self.obj,self.writeValue)
self.object_cannot_write_wrong_property_to_writableProperty(self.obj)
self.object_can_read_property(self.obj)