def test_run(self):
        mock_function_1 = MagicMock(name="mock_function_1", return_value=5)
        mock_function_2 = MagicMock(name="mock_function_2", return_value=10)

        args = [1, 2, 3]
        kwargs = {"end": "\n", "sep": " "}
        function_item_1 = FunctionItem("function_item_1", mock_function_1)
        function_item_2 = FunctionItem("function_item_2", mock_function_2, args, kwargs)
        function_item_1.action()
        function_item_2.action()

        self.assertEqual(function_item_1.get_return(), 5)
        self.assertEqual(function_item_2.get_return(), 10)
        mock_function_1.assert_any_call()
        mock_function_2.assert_called_once_with(*args, **kwargs)
    def test_run(self):
        mock_function_1 = MagicMock(name="mock_function_1", return_value=5)
        mock_function_2 = MagicMock(name="mock_function_2", return_value=10)

        args = [1, 2, 3]
        kwargs = {"end": "\n", "sep": " "}
        function_item_1 = FunctionItem("function_item_1", mock_function_1)
        function_item_2 = FunctionItem("function_item_2", mock_function_2, args, kwargs)
        function_item_1.action()
        function_item_2.action()

        self.assertEqual(function_item_1.get_return(), 5)
        self.assertEqual(function_item_2.get_return(), 10)
        mock_function_1.assert_any_call()
        mock_function_2.assert_called_once_with(*args, **kwargs)
Exemplo n.º 3
0
def main_menu():
    # create the menu object
    this_menu = CursesMenu("Teamwork Time", "Menu")

    # create the menu items
    rebuild_projects = FunctionItem("Rebuild Project Cache", get_projects,
                                    [instance, project_ids, config])
    select_project = FunctionItem("Select Project",
                                  select_projects, [config],
                                  should_exit=True)

    # build the menu
    this_menu.append_item(rebuild_projects)
    this_menu.append_item(select_project)

    # show the menu
    this_menu.show()
    this_menu.clear_screen()
    return select_project.get_return()