Пример #1
0
    def testChannelUtil(self):
        channel1 = Channel('chName1',
                           'chOwner',
                           properties=[
                               Property('location', 'propOwner', 'propVal'),
                               Property('prop1', 'propOwner', 'propVal')
                           ],
                           tags=[Tag('myTag', 'tagOwner')])
        channel2 = Channel(
            'chName2',
            'chOwner',
            properties=[
                Property('location', 'propOwner', 'propVal'),
                Property('prop2', 'propOwner', 'propVal')
            ],
            tags=[Tag('myTag', 'tagOwner'),
                  Tag('goldenOrbit', 'tagOwner')])
        channels = [channel1, channel2]
        allTags = ChannelUtil.getAllTags(channels)
        self.assertTrue(len(allTags) == 2, \
                        'expected 2 tags found ' + str(len(allTags)))
        allPropertyNames = ChannelUtil.getAllProperties(channels)
        self.assertTrue(len(allPropertyNames) == 3, \
                        'expected 3 unique properties but found ' + str(len(allPropertyNames)))

        pass
Пример #2
0
 def testValidateWithProperty(self):
     ch1 = Channel('ch1',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', '234'),
                       Property('prop1', 'propOwner', 'propVal')
                   ])
     ch2 = Channel('ch2',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', 'SR'),
                       Property('prop2', 'propOwner', 'propVal')
                   ])
     ch3 = Channel('ch3',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', 'SR:234'),
                       Property('prop2', 'propOwner', 'propVal')
                   ])
     self.assertTrue(
         ChannelUtil.validateChannelWithProperty([ch2, ch3],
                                                 Property(
                                                     'prop2', 'anyOwner',
                                                     'propVal')))
     self.assertFalse(ChannelUtil.validateChannelWithProperty([ch1, ch2, ch3], Property('prop2', 'anyOwner', 'propVal')), \
                      'Failed to correctly validate channels based on a PropertyValidator')
     pass
Пример #3
0
 def testValidateWithProperty(self):
     ch1 = Channel('ch1', 'chOwner',
                       properties=[Property('location', 'propOwner', '234'),
                                   Property('prop1', 'propOwner', 'propVal')])
     ch2 = Channel('ch2', 'chOwner',
                       properties=[Property('location', 'propOwner', 'SR'),
                                   Property('prop2', 'propOwner', 'propVal')])
     ch3 = Channel('ch3', 'chOwner',
                       properties=[Property('location', 'propOwner', 'SR:234'),
                                   Property('prop2', 'propOwner', 'propVal')])
     self.assertTrue(ChannelUtil.validateChannelWithProperty([ch2, ch3], Property('prop2', 'anyOwner', 'propVal')))
     self.assertFalse(ChannelUtil.validateChannelWithProperty([ch1, ch2, ch3], Property('prop2', 'anyOwner', 'propVal')), \
                      'Failed to correctly validate channels based on a PropertyValidator')
     pass
Пример #4
0
 def testValidateWithTag(self):   
     ch1 = Channel('chName1', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop1', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner')])
     ch2 = Channel('chName2', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop2', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner'),
                             Tag('goldenOrbit', 'tagOwner')])
     self.assertTrue(ChannelUtil.validateChannelsWithTag([ch1, ch2], Tag('myTag', 'someOwner')), \
                     'Failed to validate channels based on TagValidator')
     self.assertFalse(ChannelUtil.validateChannelsWithTag([ch1, ch2], Tag('goldenOrbit', 'someOwner')), \
                      'Failed to correctly validate channels based on a TagValidator')  
     pass
Пример #5
0
 def testValidateWithTag(self):   
     ch1 = Channel('chName1', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop1', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner')])
     ch2 = Channel('chName2', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop2', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner'),
                             Tag('goldenOrbit', 'tagOwner')])
     self.assertTrue(ChannelUtil.validateChannelsWithTag([ch1, ch2], Tag('myTag', 'someOwner')), \
                     'Failed to validate channels based on TagValidator')
     self.assertFalse(ChannelUtil.validateChannelsWithTag([ch1, ch2], Tag('goldenOrbit', 'someOwner')), \
                      'Failed to correctly validate channels based on a TagValidator')  
     pass
Пример #6
0
 def testGetAllPropValues(self):
     ch1 = Channel('ch1',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', '234'),
                       Property('prop1', 'propOwner', 'propVal')
                   ])
     ch2 = Channel('ch2',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', 'SR'),
                       Property('prop2', 'propOwner', 'propVal')
                   ])
     ch3 = Channel('ch3',
                   'chOwner',
                   properties=[
                       Property('location', 'propOwner', 'SR:234'),
                       Property('prop2', 'propOwner', 'propVal')
                   ])
     chs = [ch1, ch2, ch3]
     values = ChannelUtil.getAllPropValues(chs, propertyName='location')
     self.assertTrue('234' in values, \
                     'Failed to find property(location), value 234 for ch1')
     self.assertTrue('SR' in values, \
                     'Failed to find property(location), value SR for ch2')
     self.assertTrue('SR:234' in values, \
                     'Failed to find property(location), value SR:234 for ch3')
     pass
Пример #7
0
 def testChannelUtil(self):
     channel1 = Channel('chName1', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop1', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner')])
     channel2 = Channel('chName2', 'chOwner',
                       properties=[Property('location', 'propOwner', 'propVal'),
                                   Property('prop2', 'propOwner', 'propVal')],
                       tags=[Tag('myTag', 'tagOwner'),
                             Tag('goldenOrbit', 'tagOwner')])
     channels = [channel1, channel2]
     allTags = ChannelUtil.getAllTags(channels)
     self.assertTrue(len(allTags) == 2, \
                     'expected 2 tags found ' + str(len(allTags)))
     allPropertyNames = ChannelUtil.getAllProperties(channels)
     self.assertTrue(len(allPropertyNames) == 3, \
                     'expected 3 unique properties but found ' + str(len(allPropertyNames)))
    
     pass
Пример #8
0
 def testGetAllPropValues(self):
     ch1 = Channel('ch1', 'chOwner',
                       properties=[Property('location', 'propOwner', '234'),
                                   Property('prop1', 'propOwner', 'propVal')])
     ch2 = Channel('ch2', 'chOwner',
                       properties=[Property('location', 'propOwner', 'SR'),
                                   Property('prop2', 'propOwner', 'propVal')])
     ch3 = Channel('ch3', 'chOwner',
                       properties=[Property('location', 'propOwner', 'SR:234'),
                                   Property('prop2', 'propOwner', 'propVal')])
     chs = [ch1, ch2, ch3]
     values = ChannelUtil.getAllPropValues(chs, propertyName='location')
     self.assertTrue('234' in values, \
                     'Failed to find property(location), value 234 for ch1')
     self.assertTrue('SR' in values, \
                     'Failed to find property(location), value SR for ch2')
     self.assertTrue('SR:234' in values, \
                     'Failed to find property(location), value SR:234 for ch3')
     pass