class TestLabelPart(unittest.TestCase): def setUp(self): self.o = call_with_params(LabelPart, initialValue="My label", group="mygroup") self.p = Process("proc") self.c = Controller(self.p, "mri", [self.o]) self.p.add_controller("mri", self.c) self.p.start() self.b = self.c.block_view() def tearDown(self): self.p.stop(1) def test_init(self): assert self.o.name == "label" assert self.o.attr.value == "My label" assert self.o.attr.meta.tags == ("widget:textinput", "config", "group:mygroup") assert self.b.meta.label == "My label" def test_setter(self): self.b.label.put_value("My label2") assert self.b.label.value == "My label2" assert self.b.meta.label == "My label2"
class TestMethod(unittest.TestCase): def setUp(self): self.process = Process("proc") self.part = MyPart("test_part") self.controller = Controller("mri") self.controller.add_part(self.part) self.process.add_controller(self.controller) self.block = self.controller.block_view() self.process.start() def tearDown(self): self.process.stop(timeout=1) def test_post(self): method_view = self.block.myMethod result = method_view.post(param1="testPost", param2="y") assert result == "testPosty" def test_post_async(self): method_view = self.block.myMethod f = method_view.post_async("testAsync", "y") assert f.result() == "testAsyncy"