Beispiel #1
0
def test_tools_status():
    """ Test the tools_status function """
    instance = MenuHelper()
    core = instance.tools_status(True)
    assert isinstance(core, tuple)
    plugins = instance.tools_status(False)
    assert isinstance(plugins, tuple)
Beispiel #2
0
 def t_status(core):
     """ Get status of tools for either plugins or core """
     m_helper = MenuHelper()
     repos, tools = m_helper.tools_status(core)
     installed = 0
     custom_installed = 0
     built = 0
     custom_built = 0
     running = 0
     custom_running = 0
     normal = str(len(tools['normal']))
     # determine how many extra instances should be shown for running
     norm = set(tools['normal'])
     inst = set(tools['installed'])
     run_str = str(len(tools['normal']) + len(inst - norm))
     for tool in tools['running']:
         # check for multi instances too for running
         if tool in tools['normal']:
             running += 1
         elif re.sub(r'\d+$', '', tool) in tools['normal']:
             running += 1
         else:
             custom_running += 1
     for tool in tools['built']:
         if tool in tools['normal']:
             built += 1
         else:
             custom_built += 1
     for tool in tools['installed']:
         if tool in tools['normal']:
             installed += 1
         elif re.sub(r'\d+$', '', tool) not in tools['normal']:
             custom_installed += 1
     tools_str = str(running + custom_running) + '/' + run_str + ' running'
     if custom_running > 0:
         tools_str += ' (' + str(custom_running) + ' custom)'
     tools_str += ', ' + str(built + custom_built) + '/' + normal + ' built'
     if custom_built > 0:
         tools_str += ' (' + str(custom_built) + ' custom)'
     tools_str += ', ' + str(installed + custom_installed) + '/' + normal
     tools_str += ' installed'
     if custom_built > 0:
         tools_str += ' (' + str(custom_installed) + ' custom)'
     return tools_str, (running, custom_running, normal, repos)