示例#1
0
class TestAttribute(unittest.TestCase):

    def setUp(self):
        self.meta = StringMeta()

    def test_init(self):
        a = self.meta.make_attribute()
        self.assertIs(self.meta, a.meta)
        self.assertEquals(a.value, "")
        self.assertEquals("epics:nt/NTScalar:1.0", a.typeid)

    def test_set_value(self):
        value = "test_value"
        a = self.meta.make_attribute()
        a.process = Mock()
        a.set_value(value)
        self.assertEquals(a.value, value)
        a.process.report_changes.assert_called_once_with([['value'], value])

    def test_handle_request(self):
        a = self.meta.make_attribute()
        request = Put(endpoint=["1", "2", "value"], value=Mock())
        put_function = Mock()
        a.handle_request(request, put_function)
        put_function.assert_called_once_with(self.meta, request.value)
示例#2
0
 def setUp(self):
     self.callback_result = 0
     self.callback_value = ''
     meta = StringMeta("meta for unit tests")
     self.proc = MagicMock(q=queue.Queue())
     self.proc.create_queue = MagicMock(side_effect=queue.Queue)
     self.block = Block()
     self.block.set_process_path(self.proc, ("testBlock",))
     self.attr = meta.make_attribute()
     self.attr2 = meta.make_attribute()
     self.method = MethodMeta("method for unit tests")
     self.method.returns.set_elements(ElementMap(dict(ret=StringMeta())))
     self.method2 = MethodMeta("method for unit tests")
     self.block.replace_endpoints(
         dict(testFunc=self.method, testFunc2=self.method2,
              testAttr=self.attr, testAttr2=self.attr2))
     self.bad_called_back = False
示例#3
0
 def setUp(self):
     self.callback_result = 0
     self.callback_value = ''
     meta = StringMeta("meta for unit tests")
     self.proc = MagicMock(q=queue.Queue())
     self.proc.create_queue = MagicMock(side_effect=queue.Queue)
     self.block = Block()
     self.block.set_process_path(self.proc, ("testBlock", ))
     self.attr = meta.make_attribute()
     self.attr2 = meta.make_attribute()
     self.method = MethodMeta("method for unit tests")
     self.method.returns.set_elements(ElementMap(dict(ret=StringMeta())))
     self.method2 = MethodMeta("method for unit tests")
     self.block.replace_endpoints(
         dict(testFunc=self.method,
              testFunc2=self.method2,
              testAttr=self.attr,
              testAttr2=self.attr2))
     self.bad_called_back = False