Example #1
0
    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')
Example #2
0
    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')
Example #3
0
 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)
Example #4
0
 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")
Example #5
0
 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")
Example #6
0
 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)
Example #7
0
 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))
Example #8
0
 def testClearing(self):
     '''
     Call pack when the label was not set
     '''
     label = Label.Field()
     self.assertRaises(Exception.A429NoData,label.pack)
Example #9
0
 def testGetDataNoData(self):
     '''
     Call get data when the label was not set
     '''
     label = Label.Field()
     self.assertRaises(Exception.A429NoData,label.getData)
Example #10
0
 def testLabelLowerLimit(self):
     """
     Confirm that value above 377 are rejected
     """
     label = Label.Field()
     self.assertRaises(Exception.A429MsgRangeError,label.setData,'-1')
Example #11
0
 def testNonOctal(self):
     label = Label.Field()
     self.assertRaises(Exception.A429MsgRangeError,label.setData,'378')
Example #12
0
 def testCanRepresentItself(self):
     try:
         Label.Field()
     except Exception:
         self.fail("LabelField cannot represent itself")