Esempio n. 1
0
    def test_get_tab_complete_list(self):
        tab_complete_list = [
            'about', 'add ', 'all', 'clear', 'cmd', 'create ', 'exit',
            'export ', 'false', 'file', 'fingerprints', 'group ', 'help',
            'history ', 'join ', 'localkey', 'logging ', 'msg ', 'names',
            'nick ', 'notify ', 'passwd ', 'psk', 'reset', 'rm', 'rmlogs ',
            'set ', 'settings', 'store ', 'true', 'unread', 'key1 ', 'key2 ',
            '[email protected] ', '[email protected] ', 'Alice ',
            '[email protected] ', 'Bob ', 'testgroup ', 'whisper '
        ]

        self.assertEqual(
            set(
                get_tab_complete_list(self.contact_list, self.group_list,
                                      self.settings)), set(tab_complete_list))
        self.assertIsInstance(
            get_tab_completer(self.contact_list, self.group_list,
                              self.settings), types.FunctionType)

        completer = get_tab_completer(self.contact_list, self.group_list,
                                      self.settings)
        options = completer('a', state=0)

        self.assertEqual(options, 'about')
        self.assertIsNone(completer('a', state=5))
Esempio n. 2
0
    def test_get_tab_complete_list(self):
        # Setup
        contact_list = ContactList(nicks=['Alice', 'Bob'])
        group_list   = GroupList(groups=['testgroup'])
        settings     = Settings(key_list = ['key1', 'key2'])

        tclst = ['about', 'add ', 'all', 'clear', 'cmd', 'create ', 'exit', 'export ', 'false', 'file', 'fingerprints',
                 'group ', 'help', 'history ', 'localkey', 'logging ', 'msg ', 'names', 'nick ', 'notify ', 'passwd ',
                 'psk', 'reset', 'rm ', 'set ', 'settings', 'store ', 'true', 'unread', 'key1 ', 'key2 ',
                 '[email protected] ', '[email protected] ', 'Alice ', '[email protected] ', 'Bob ', 'testgroup ']

        # Test
        self.assertEqual(set(get_tab_complete_list(contact_list, group_list, settings)), set(tclst))
        self.assertIsInstance(get_tab_completer(contact_list, group_list, settings), types.FunctionType)
Esempio n. 3
0
    def test_get_tab_complete_list(self):
        tab_complete_list = [
            a + ' ' for a in self.contact_list.get_list_of_addresses()
        ]
        tab_complete_list += [
            i + ' ' for i in self.group_list.get_list_of_hr_group_ids()
        ]
        tab_complete_list += [s + ' ' for s in self.settings.key_list]
        tab_complete_list += [s + ' ' for s in self.gateway.settings.key_list]

        tc_list = get_tab_complete_list(self.contact_list, self.group_list,
                                        self.settings, self.gateway)
        self.assertTrue(set(tab_complete_list) < set(tc_list))
        self.assertIsInstance(
            get_tab_completer(self.contact_list, self.group_list,
                              self.settings, self.gateway), types.FunctionType)

        completer = get_tab_completer(self.contact_list, self.group_list,
                                      self.settings, self.gateway)
        options = completer('a', state=0)

        self.assertEqual(options, 'all')
        self.assertIsNone(completer('a', state=5))