Ejemplo n.º 1
0
 def check_attribute(self,child,attribute):
     t = Time()
     t.configure({'name':'time','parent':None})
     c = t.get_child(child)
     c_value = c.get_child(attribute).get()
     
     if attribute != 'milliseconds':
         attributes = {'year':0,'month':1,
                       'day':2,'hour':3,
                       'weekday':6,'minute':4,
                       'second':5}
     
         if child == 'UTC':
             tuple = time.gmtime()
         elif child == 'local':
             tuple = time.localtime()            
         
         real_value = tuple[attributes[attribute]]
         if c_value != real_value:
             self.fail(child + '  "' + attribute +'" is not correct\n' +
                       child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' +
                       'Correct value: ' + str(real_value))
     else:
         t = time.time()
         real_value = (t - int(t)) *1000
         if c_value < (real_value +.5) and c_value > (real_value -.5):
             pass
         else:
             self.fail(child + ' "' + attribute +'" is not correct\n' +
                       child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' +
                       'Correct value: ' + str(real_value))
Ejemplo n.º 2
0
    def test_local_children(self):
        children = [
            'year', 'day', 'month', 'hour', 'minute', 'weekday', 'second',
            'milliseconds'
        ]
        t = Time()
        t.configure({'name': 'time', 'parent': None})
        l = t.get_child('local')
        for c in children:
            if c not in l.children_names():
                msg = 'Child "' + str(c) + '" was not found in Local children '
                for x in l.children_names():
                    msg += str(x) + ','
                msg = msg[:-1] + '\n'
                msg = msg + 'Child "' + str(
                    c) + '" should be an inherent child of Local'
                self.fail(msg)

        if len(children) != len(l.children_names()):
            msg = 'Local has a different amount of inherent children then I know about!\n'
            msg += 'I think it should have only:\n'
            for c in children:
                msg += c + '\n'
            msg += '\nLocal has Children:\n'
            for c in l.children.names():
                msg += c + '\n'
            self.fail(msg)
 def __init__(self, name, poll_all):
     self._name = name
     self._run = 0
     self._running = 0
     self._sid = 0
     self._changed_values = {}
     self._values = {}
     self._poll_all = poll_all
     self.DELAY = 0.0
     self.__doc['DELAY'] = 'Delay in seconds between polling for values.'
     root = as_internal_node('/')
     if not root.has_child(name):
         anchor = CompositeNode()
         anchor.configure({'name':name,'parent':root})
         self._anchor = anchor
         t = Time()
         t.configure({'name':'time', 'parent':anchor})
         t.start()
     return
Ejemplo n.º 4
0
 def test_UTC_children(self):
     children = ['year','month','day','hour','minute','weekday','second','milliseconds']
     t = Time()
     t.configure({'name':'time','parent':None})
     u = t.get_child('UTC')
     for c in children:   
         if c not in u.children_names():
             msg = 'Child "' + str(c) + '" was not found in UTC children ' 
             for x in u.children_names():
                 msg += str(x) + ','
             msg = msg[:-1] + '\n'
             msg = msg + 'Child "' + str(c) + '" should be an inherent child of UTC' 
             self.fail(msg)
     if len(children) != len(u.children_names()):
         msg = 'UTC has a different amount of inherent children then I know about!\n'
         msg += 'I think it should have only:\n'
         for c in children:
             msg += c + '\n'
         msg += '\nUTC has Children:\n'
         for c in u.children_names():
             msg += c + '\n'
         self.fail(msg)
Ejemplo n.º 5
0
    def check_attribute(self, child, attribute):
        t = Time()
        t.configure({'name': 'time', 'parent': None})
        c = t.get_child(child)
        c_value = c.get_child(attribute).get()

        if attribute != 'milliseconds':
            attributes = {
                'year': 0,
                'month': 1,
                'day': 2,
                'hour': 3,
                'weekday': 6,
                'minute': 4,
                'second': 5
            }

            if child == 'UTC':
                tuple = time.gmtime()
            elif child == 'local':
                tuple = time.localtime()

            real_value = tuple[attributes[attribute]]
            if c_value != real_value:
                self.fail(child + '  "' + attribute + '" is not correct\n' +
                          child + ' ' + attribute + ' came back as: ' +
                          str(c_value) + '\n' + 'Correct value: ' +
                          str(real_value))
        else:
            t = time.time()
            real_value = (t - int(t)) * 1000
            if c_value < (real_value + .5) and c_value > (real_value - .5):
                pass
            else:
                self.fail(child + ' "' + attribute + '" is not correct\n' +
                          child + ' ' + attribute + ' came back as: ' +
                          str(c_value) + '\n' + 'Correct value: ' +
                          str(real_value))
Ejemplo n.º 6
0
 def test_for_local_child(self):
     t = Time()
     t.configure({'name': 'time', 'parent': None})
     self.failUnless(t.has_child('local'), 'No local child!')
Ejemplo n.º 7
0
 def test_for_UTC_child(self):
     t = Time()
     t.configure({'name': 'time', 'parent': None})
     self.failUnless(t.has_child('UTC'), 'No UTC child!')
Ejemplo n.º 8
0
 def test_for_local_child(self):
     t = Time()
     t.configure({'name':'time','parent':None})
     self.failUnless(t.has_child('local'),'No local child!')
Ejemplo n.º 9
0
 def test_for_UTC_child(self):
     t = Time()
     t.configure({'name':'time','parent':None})
     self.failUnless(t.has_child('UTC'),'No UTC child!')