Пример #1
0
class TestStaticDataStore(unittest.TestCase):
    def setUp(self):
        self.walker = mock.Mock()

        self.data_store = StaticDataStore([
            "message 1", "message 2"])
        self.data_store.register(self.walker)

    def test_setup(self):
        self.assertEqual(len(self.data_store.walkers), 1)

        self.data_store.setup()
        self.walker.recv.assert_has_calls(
            [mock.call("message 1"), mock.call("message 2")], any_order=True)

    def test_register_new_walker(self):
        walker2 = mock.Mock()
        self.data_store.register(walker2)

        self.assertEqual(len(self.data_store.walkers), 2)

        self.data_store.setup()
        self.walker.recv.assert_has_calls(
            [mock.call("message 1"), mock.call("message 2")], any_order=True)
        walker2.recv.assert_has_calls(
            [mock.call("message 1"), mock.call("message 2")], any_order=True)

    def test_unregister(self):
        self.data_store.unregister(self.walker)
        self.assertEqual(len(self.data_store.walkers), 0)
Пример #2
0
    def setUp(self):
        self.messages = [
            ["aaa1", "aaa2", "aaa3"],
            ["bbb1", "bbb2", "bbb3"],
            ["ccc1", "ccc2", "ccc3"]
        ]
        store = StaticDataStore(self.messages)
        main_context = DisplayerContext(store, self)

        messages2 = [
            ["ddd1", "ddd2", "ddd3"],
            ["eee1", "eee2", "eee3"],
            ["fff1", "fff2", "fff3"]
        ]
        store2 = StaticDataStore(messages2)
        self.other_context = DisplayerContext(store2, self)

        context = Context(
            Config(), main_context=main_context,
            other_contexts=[self.other_context])
        self.widget = ParentFrame(context)

        store.setup()
Пример #3
0
    def setUp(self):
        self.walker = mock.Mock()

        self.data_store = StaticDataStore([
            "message 1", "message 2"])
        self.data_store.register(self.walker)