def testEqual(self): field1 = Label.Field() field2 = Label.Field() self.assertEqual(field1,field2,'Label Field Comparison not working') field1.setData('0365') field2.setData('0365') self.assertEqual(field1,field2,'Label Field Comparison not working')
def testDifferent(self): field1 = Label.Field() field1.setData('0365') field2 = Label.Field() field2.setData('0364') self.assertNotEqual(field1,field2,'Label Field Comparison not working') field3 = Label.Field() self.assertNotEqual(field1,field3,'Label Field Comparison not working')
def testLabelFormat(self): """ Confirm that an integer or floating point value is not accepted a labeValue """ label = Label.Field() self.assertRaises(Exception.A429Exception,label.setData,5) self.assertRaises(Exception.A429Exception,label.setData,8.5)
def testLabelUnpacking(self): """ unpack different labels and confirm they are decoded properly """ for label,packed in self.refValues: labelField = Label.Field() labelField.unpack(packed) self.assertEqual(labelField.getData(),int(str(label),8), "Label Not Unpacked Properly")
def testLabelPacking(self): """ pack different labels and confirm they are coded properly """ for label,packed in self.refValues: labelField = Label.Field() labelField.setData(str(label)) self.assertEqual(labelField.pack(),packed, "Label Not Packed Properly")
def testPackNoData(self): ''' Call pack when the label was not set ''' labelField = Label.Field() labelField.setData(str(41)) labelField.clear() self.assertRaises(Exception.A429NoData,labelField.pack)
def __init__(self,name,parity='odd'): ''' Create an A429 Message by simply adding a label and a parity bit Note that the parity is odd by default but can be modified as necessary ''' self.name = name self._fields = list() self.fieldAdditionRules = (self.__field_overlaps,self.__field_name_already_exist) self.addField(Label.Field()) self.addField(Parity.Field(parity))
def testClearing(self): ''' Call pack when the label was not set ''' label = Label.Field() self.assertRaises(Exception.A429NoData,label.pack)
def testGetDataNoData(self): ''' Call get data when the label was not set ''' label = Label.Field() self.assertRaises(Exception.A429NoData,label.getData)
def testLabelLowerLimit(self): """ Confirm that value above 377 are rejected """ label = Label.Field() self.assertRaises(Exception.A429MsgRangeError,label.setData,'-1')
def testNonOctal(self): label = Label.Field() self.assertRaises(Exception.A429MsgRangeError,label.setData,'378')
def testCanRepresentItself(self): try: Label.Field() except Exception: self.fail("LabelField cannot represent itself")