Ejemplo n.º 1
0
def run(arguments: MainArguments) -> None:
    """
    Orchestrates the primary business functions of LMS Harmonizer

    Parameters
    ----------
    arguments: MainArguments
        An object containing the system arguments
    """

    logger.info("Starting the Ed-Fi LMS Harmonizer")

    try:
        adapter = arguments.get_adapter()
        migrate(arguments.engine, adapter)

        exceptions_report_directory = arguments.exceptions_report_directory

        harmonize_users(arguments.engine, adapter)
        harmonize_sections(arguments.engine, adapter)
        harmonize_assignments(arguments.engine, adapter)
        harmonize_assignment_submissions(arguments.engine, adapter)

        if exceptions_report_directory is not None:
            create_exception_reports(arguments.engine, adapter, exceptions_report_directory)

        print_summary(adapter)

        logger.info("Finishing the Ed-Fi LMS Harmonizer")
    finally:
        arguments.get_adapter().engine.dispose()
    def test_given_there_are_no_exceptions_then_it_should_log_it_to_debug(
        self, ) -> None:
        # Arrange
        adapter = Mock(spec=Adapter)
        adapter.get_int.return_value = 0

        # Act
        with self.assertLogs(level="DEBUG") as log:
            exceptions_reports.print_summary(adapter)

        assert "There are no unmatched" in str(log.output)
    def test_given_there_is_one_unmatched_submission_then_it_should_report_a_warning(
        self, ) -> None:
        # Arrange
        adapter = Mock(spec=Adapter)
        adapter.get_int.side_effect = [
            0,  # output for users
            0,  # output for sections
            0,  # output for assignments
            1,  # output for submissions
            0,  # output for assignment type descriptor
            0,  # output for submission status descriptor
        ]

        # Act
        with self.assertLogs() as log:
            exceptions_reports.print_summary(adapter)

        assert "There are 0 unmatched Assignments and 1 unmatched Submissions" in str(
            log.output)