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