Example #1
0
    def test_display_class_selection_menu(self):
        # capture print function
        # assert captured_print_function == expected_print_statements.
        with patch('dionysus_app.UI_menus.class_functions_UI.print'
                   ) as mocked_print:
            display_class_selection_menu(self.enumerated_registry)

            print_calls = [
                mock.call(printed_str)
                for printed_str in self.expected_print_statements
            ]
            assert mocked_print.call_args_list == print_calls
Example #2
0
def select_classlist():
    """
    Display list of existent classes from class_registry and allow user to select one, returning the name of the
    selected class.

    :return: str
    """
    class_options = create_class_list_dict()
    display_class_selection_menu(
        class_options)  # TODO: Select class or redirect to create new class.

    selected_class = take_class_selection(class_options)

    return selected_class
Example #3
0
def select_student(class_name: str):
    """
    Display list of students in class and allow user to select one, returning the name of the
    selected student.

    :param class_name: str
    :return: str
    """
    student_options = create_student_list_dict(class_name)
    display_class_selection_menu(student_options)

    selected_student = take_student_selection(student_options)

    return selected_student
Example #4
0
def select_classlist() -> Any:
    """
    Prompt user to select a class from list, return selected Class.

    Display list of existent classes from class_registry and allow user to select one, returning the name of the
    selected class.

    :return: Any - the type ClassIdentifier.id is for backend database.
    """
    class_options = create_class_list_dict()
    display_class_selection_menu(class_options)

    selected_class = take_class_selection(class_options)

    return selected_class.id
Example #5
0
    def test_display_class_selection_menu(self):
        """User feedback rendered as expected."""
        enumerated_registry = test_registry_data_set['enumerated_dict']
        expected_enum_class_strings = [
            f'{numeral}. {class_.name}'
            for numeral, class_ in enumerated_registry.items()
        ]
        expected_print_statements = [
            "Select class from list:",
        ] + expected_enum_class_strings

        # capture print function
        # assert captured_print_function == expected_print_statements.
        with patch('builtins.print') as mocked_print:
            display_class_selection_menu(enumerated_registry)

            print_calls = [
                mock.call(printed_str)
                for printed_str in expected_print_statements
            ]
            assert mocked_print.call_args_list == print_calls