示例#1
0
    def __init__(self, name):
        config_script = {
            'VERSION' : { '*' : [('VERSION', CANTO_PROTOCOL_COMPATIBLE)] },
            'CONFIGS' : { '*' : [('CONFIGS', { "CantoCurses" : config.template_config })] },
                
        }

        self.config_backend = TestBackend("config", config_script)

        config.init(self.config_backend, CANTO_PROTOCOL_COMPATIBLE)

        self.config_backend.inject("NEWTAGS", [ "maintag:Tag(0)", "maintag:Tag(1)", "maintag:Tag(2)" ])

        tagcore_script = generate_item_script(3, 20, "maintag:Tag(%d)", "Story(%d,%d)",
                { "title" : "%d,%d - title", "link" : "http://example.com/%d/%d",
                    "description" : "Description(%d,%d)", "canto-tags" : "",
                    "canto-state" : "" }
        ) 

        self.tag_backend = TestBackend("tagcore", tagcore_script)

        tag_updater.init(self.tag_backend)

        # The standard opening of c-c, the tags can be in any state, but for the
        # purposes of testing, we want to make sure that the tagcores are in a known
        # state or the rest of this stuff will be racy.

        # Fortunately the real-world opening case is tested every time you run c-c =P

        # 9 = 3 tags * 3 responses per ITEMS call (ITEMS, ITEMSDONE, and ATTRIBUTES)

        while len(self.tag_backend.procd) != 9:
            print("len: %s" % len(self.tag_backend.procd))
            time.sleep(0.1)

        if len(alltagcores) != 3:
            raise Exception("Didn't get all tags!")
        if len(alltagcores[0]) != 20:
            raise Exception("Didn't get all items in tagcore[0]")
        if len(alltagcores[1]) != 20:
            raise Exception("Didn't get all items in tagcore[1]")

        gui_script = {}

        self.gui_backend = TestBackend("gui", gui_script)

        self.gui = CantoCursesGui(self.gui_backend)
        self.wait_on_update()

        Test.__init__(self, name)