示例#1
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)
示例#2
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))
示例#3
0
 def __init__(self):
     ServiceNode.__init__(self)
     # Instantiate implicit children.
     from mpx.service.interactive import InteractiveService
     InteractiveService().configure({
         'name': 'Interactive Service',
         'parent': self,
         'debug': 0,
         'port': 9666,
         'interface': 'localhost'
     })
     from mpx.service.time import Time
     Time().configure({'name': 'time', 'parent': self})
     from mpx.service.session import SessionManager
     SessionManager().configure({'name': 'session_manager', 'parent': self})
     from mpx.service.user_manager import UserManager
     UserManager().configure({'name': 'User Manager', 'parent': self})
     from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER
     SUBSCRIPTION_MANAGER.configure({
         'name': 'Subscription Manager',
         'parent': self
     })
     # Guarantee that /services/garbage_collector will exist, whether or not
     # there is an entry in the XML file.
     from mpx.service.garbage_collector import GARBAGE_COLLECTOR
     # @todo Make ReloadableSingleton!
     GARBAGE_COLLECTOR.configure({
         'name': 'garbage_collector',
         'parent': self
     })
示例#4
0
 def test_Time(self):
     t = time.time()
     t2 = Time().get()
     upper_limit = t + .05
     lower_limit = t - .05
     # Getting 2 different times so as long as we are close!
     self.failUnless(
         t2 < upper_limit and t2 > lower_limit, 'Time did not match' +
         ' time.time()=' + str(t) + ' and Time().get()=' + str(t2))
示例#5
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)
示例#6
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))
 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
示例#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!')
示例#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!')
示例#10
0
 def test_for_local_child(self):
     t = Time()
     t.configure({'name':'time','parent':None})
     self.failUnless(t.has_child('local'),'No local child!')
示例#11
0
 def test_for_UTC_child(self):
     t = Time()
     t.configure({'name':'time','parent':None})
     self.failUnless(t.has_child('UTC'),'No UTC child!')