コード例 #1
0
 def test_get(self):
     sv = SimpleValue()
     sv.configure({'name': 'simple_value', 'parent': None, 'value': 100})
     value = sv.get()
     self.failIf(value != 100,
                 'Test get failed, value returned: ' + str(value))
     return
コード例 #2
0
 def test_get(self):
     sv = SimpleValue()
     sv.configure({'name':'simple_value','parent':None,'value':100})
     value = sv.get() 
     self.failIf(value != 100,'Test get failed, value returned: ' +
                 str(value))
     return
コード例 #3
0
 def test_20_PeriodicRelayDriver_config(self, quite=0):
     self.PRINT("ENTER: test_20_PeriodicRelayDriver_config: %s\n",
                "*"*15, quite=quite)
     pts = self.test_10_PeriodicRelayDriver(1)
     output = SimpleValue()
     output.configure({'name':'output',
                       'parent':None,
                       'value':0})
     input = SimpleValue()
     input.configure({'name':'input',
                       'parent':None,
                       'value':0})
     level = 0 # No debugging output.
     if TestCase.VERBOSE != 0:
         level = 2 # DEBUG2
     pts.configure({'parent':output,
                    'name':'periodic_relay_driver',
                    'input':input,
                    'debug':level})
     self.PRINT("EXIT:  test_20_PeriodicRelayDriver_config: %s\n",
                "*"*15, quite=quite)
     return pts
コード例 #4
0
 def test_20_PeriodicRelayDriver_config(self, quite=0):
     self.PRINT("ENTER: test_20_PeriodicRelayDriver_config: %s\n",
                "*" * 15,
                quite=quite)
     pts = self.test_10_PeriodicRelayDriver(1)
     output = SimpleValue()
     output.configure({'name': 'output', 'parent': None, 'value': 0})
     input = SimpleValue()
     input.configure({'name': 'input', 'parent': None, 'value': 0})
     level = 0  # No debugging output.
     if TestCase.VERBOSE != 0:
         level = 2  # DEBUG2
     pts.configure({
         'parent': output,
         'name': 'periodic_relay_driver',
         'input': input,
         'debug': level
     })
     self.PRINT("EXIT:  test_20_PeriodicRelayDriver_config: %s\n",
                "*" * 15,
                quite=quite)
     return pts
コード例 #5
0
class TestCase(DefaultTestFixture):
    def setUp(self):
        DefaultTestFixture.setUp(self)
        self.root = as_internal_node('/')
        self.input = CompositeNode()
        self.output = CompositeNode()
        self.input.configure({'parent':self.root, 'name':'input'})
        self.output.configure({'parent':self.root, 'name':'output'})
        self.input_value = SimpleValue()
        self.output_value = SimpleValue()
        self.input_value.configure({'parent':self.input, 'name':'value'})
        self.output_value.configure({'parent':self.output, 'name':'value'})
        self.aliases = Aliases()
        self.aliases.configure({'parent':self.root, 'name':'aliases'})
        self.alias_input = Alias()
        self.alias_input.configure({'parent':self.aliases, 'name':'input',
                                    'node_url':'/input/value'})
        self.alias_output = Alias()
        self.alias_output.configure({'parent':self.aliases, 'name':'output',
                                    'node_url':'/output/value'})
        self.input_value.set(1)
        self.output_value.set(0)
        return
    def tearDown(self):
        try:
            self.root.prune()
            self.root = None
        finally:
            DefaultTestFixture.tearDown(self)
        return
    def test_simple_case(self):
        driver = PeriodicDriver()
        driver.configure({'name':'driver','parent':self.output_value,
                          'input':self.input_value})
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return
    def test_alias_input(self):
        driver = PeriodicDriver()
        driver.configure({'name':'driver','parent':self.output_value,
                          'input':self.alias_input})
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return
    def test_alias_output(self):
        driver = PeriodicDriver()
        driver.configure({'name':'driver','parent':self.output,
                          'input':self.input_value, 'output':self.alias_output,
                          })
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return
    def test_deferred_input(self):
        driver = PeriodicDriver()
        driver.configure({'name':'driver','parent':self.output_value,
                          'input':'/aliases/deferred_input',
                          'period':0.01})
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        pause(0.1)
        Alias().configure({'parent':self.aliases, 'name':'deferred_input',
                           'node_url':'/input/value'})
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return
コード例 #6
0
class TestCase(DefaultTestFixture):
    def setUp(self):
        DefaultTestFixture.setUp(self)
        self.root = as_internal_node('/')
        self.input = CompositeNode()
        self.output = CompositeNode()
        self.input.configure({'parent': self.root, 'name': 'input'})
        self.output.configure({'parent': self.root, 'name': 'output'})
        self.input_value = SimpleValue()
        self.output_value = SimpleValue()
        self.input_value.configure({'parent': self.input, 'name': 'value'})
        self.output_value.configure({'parent': self.output, 'name': 'value'})
        self.aliases = Aliases()
        self.aliases.configure({'parent': self.root, 'name': 'aliases'})
        self.alias_input = Alias()
        self.alias_input.configure({
            'parent': self.aliases,
            'name': 'input',
            'node_url': '/input/value'
        })
        self.alias_output = Alias()
        self.alias_output.configure({
            'parent': self.aliases,
            'name': 'output',
            'node_url': '/output/value'
        })
        self.input_value.set(1)
        self.output_value.set(0)
        return

    def tearDown(self):
        try:
            self.root.prune()
            self.root = None
        finally:
            DefaultTestFixture.tearDown(self)
        return

    def test_simple_case(self):
        driver = PeriodicDriver()
        driver.configure({
            'name': 'driver',
            'parent': self.output_value,
            'input': self.input_value
        })
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return

    def test_alias_input(self):
        driver = PeriodicDriver()
        driver.configure({
            'name': 'driver',
            'parent': self.output_value,
            'input': self.alias_input
        })
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return

    def test_alias_output(self):
        driver = PeriodicDriver()
        driver.configure({
            'name': 'driver',
            'parent': self.output,
            'input': self.input_value,
            'output': self.alias_output,
        })
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return

    def test_deferred_input(self):
        driver = PeriodicDriver()
        driver.configure({
            'name': 'driver',
            'parent': self.output_value,
            'input': '/aliases/deferred_input',
            'period': 0.01
        })
        self.assert_(self.output_value.get() == 0,
                     "Output already non-zero, bogus test...")
        driver.start()
        pause(0.1)
        Alias().configure({
            'parent': self.aliases,
            'name': 'deferred_input',
            'node_url': '/input/value'
        })
        timeout_at = time.time() + 1.0
        while self.output_value.get() == 0:
            if time.time() > timeout_at:
                self.fail("self.output_value never driven to 1.")
            pause(0.01)
        return