Ejemplo n.º 1
0
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section(connection, SIS_ID,
                               SOURCE_SYSTEM)  # Matching section
            insert_edfi_section(connection, SIS_ID,
                                SECTION_ID)  # Matching section

            insert_lms_section(connection, NOT_MATCHING_SIS_ID,
                               SOURCE_SYSTEM)  # Not matching section
            insert_edfi_section(
                connection, "also_not_matching_sis_id")  # Not matching section

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSSection = query(
                connection,
                "SELECT EdFiSectionId, SISSectionIdentifier from lms.LMSSection",
            )
            assert len(LMSSection) == 2
            assert LMSSection[0]["SISSectionIdentifier"] == SIS_ID
            assert LMSSection[0]["EdFiSectionId"] == SECTION_ID
            assert LMSSection[1]["SISSectionIdentifier"] == NOT_MATCHING_SIS_ID
            assert LMSSection[1]["EdFiSectionId"] is None
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID, EMAIL, SOURCE_SYSTEM)
            insert_lms_user(connection, NOT_MATCHING_SIS_ID,
                            NOT_MATCHING_EMAIL, SOURCE_SYSTEM)

            insert_edfi_student_with_usi(connection, 1, STUDENT_ID)
            insert_edfi_student_electronic_mail(connection, 1, EMAIL)

            insert_edfi_student_with_usi(connection, 2,
                                         NOT_MATCHING_STUDENT_ID)
            insert_edfi_student_electronic_mail(connection, 2,
                                                "*****@*****.**")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSUser = query(
                connection,
                "SELECT EdFiStudentId, SourceSystemIdentifier from lms.LMSUser",
            )
            assert len(LMSUser) == 2
            assert LMSUser[0]["SourceSystemIdentifier"] == SIS_ID
            assert LMSUser[0]["EdFiStudentId"] == STUDENT_ID
            assert LMSUser[1]["SourceSystemIdentifier"] == NOT_MATCHING_SIS_ID
            assert LMSUser[1]["EdFiStudentId"] is None
Ejemplo n.º 3
0
    def it_should_return_one_exception(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section(connection, SIS_ID,
                               SOURCE_SYSTEM)  # Matching section
            insert_edfi_section(connection, SIS_ID,
                                SECTION_ID)  # Matching section

            insert_lms_section(connection, NOT_MATCHING_SIS_ID,
                               SOURCE_SYSTEM)  # Not matching section
            insert_edfi_section(
                connection, "also_not_matching_sis_id")  # Not matching section

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSSection",
            )

            assert len(exceptions) == 1
            assert exceptions[0][
                "SourceSystemIdentifier"] == NOT_MATCHING_SIS_ID
    def it_should_ignore_the_deleted_record(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user_deleted(connection, SIS_ID, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, UNIQUE_ID, STUDENT_ID)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSUser = query(connection, "SELECT EdFiStudentId from lms.LMSUser")
            assert len(LMSUser) == 1
            assert LMSUser[0]["EdFiStudentId"] is None
Ejemplo n.º 5
0
    def it_should_ignore_the_deleted_record(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section_deleted(connection, SIS_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_ID, SECTION_ID)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSSection = query(connection,
                               "SELECT EdFiSectionId from lms.LMSSection")
            assert len(LMSSection) == 1
            assert LMSSection[0]["EdFiSectionId"] is None
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID, EMAIL, SOURCE_SYSTEM)
            insert_edfi_student_with_usi(connection, 1, STUDENT_ID)
            insert_edfi_student_electronic_mail(connection, 1, EMAIL)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSUser = query(connection,
                            "SELECT EdFiStudentId from lms.LMSUser")
        assert len(LMSUser) == 1
        assert LMSUser[0]["EdFiStudentId"] == STUDENT_ID
Ejemplo n.º 7
0
    def it_should_return_no_exceptions(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, UNIQUE_ID, STUDENT_ID)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSUser")

            assert len(exceptions) == 0
Ejemplo n.º 8
0
    def it_should_return_no_exceptions(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section_deleted(connection, SIS_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_ID, SECTION_ID)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSSection",
            )

            assert len(exceptions) == 0
    def it_should_return_one_exception_when_theres_one_exception(
        test_db_config: MssqlServerConfig
    ):
        descriptor_namespace = descriptor_namespace_for(SOURCE_SYSTEM)
        category_descriptor_id = 1
        source_system_descriptor_id = 2
        section_identifier = 1

        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(connection, descriptor_namespace, ASSIGNMENT_CATEGORY)
            insert_lmsx_assignmentcategory_descriptor(
                connection, category_descriptor_id
            )

            insert_descriptor(connection, descriptor_namespace, SOURCE_SYSTEM)
            insert_lmsx_sourcesystem_descriptor(connection, source_system_descriptor_id)

            insert_lms_section(connection, SIS_SECTION_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute(
                """UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)"""
            )

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                SOURCE_SYSTEM,
                section_identifier,
                ASSIGNMENT_CATEGORY,
            )

        # act
        run_harmonizer(test_db_config)
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            connection.execute(
                """DELETE FROM LMSX.ASSIGNMENT"""
            )

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            result = query(connection, QUERY_FOR_ASSIGNMENT_EXCEPTIONS)

        assert result[0]['count'] == 1
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, "sis_id_1", "*****@*****.**", SOURCE_SYSTEM)
            insert_lms_user(connection, "sis_id_2", "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, "not_matching_sis_id_1")
            insert_edfi_student(connection, "not_matching_sis_id_2")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSUser = query(connection, "SELECT EdFiStudentId from lms.LMSUser")
            assert len(LMSUser) == 2
            assert LMSUser[0]["EdFiStudentId"] is None
            assert LMSUser[1]["EdFiStudentId"] is None
Ejemplo n.º 11
0
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section(connection, SIS_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_ID, SECTION_ID)

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSSection = query(
                connection,
                "SELECT EdFiSectionId from lms.LMSSection",
            )
            assert len(LMSSection) == 1
            assert LMSSection[0]["EdFiSectionId"] == SECTION_ID
    def it_should_not_count_it_as_an_exception(
        test_db_config: MssqlServerConfig
    ):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_descriptor(
                connection, descriptor_namespace_for(SOURCE_SYSTEM), ASSIGNMENT_CATEGORY
            )
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(
                connection, descriptor_namespace_for(SOURCE_SYSTEM), SOURCE_SYSTEM
            )
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_lms_section(connection, SIS_SECTION_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute(
                """UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)"""
            )

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                SOURCE_SYSTEM,
                1,
                ASSIGNMENT_CATEGORY,
            )

        run_harmonizer(test_db_config)

        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            connection.execute(
                "UPDATE LMS.ASSIGNMENT SET LastModifiedDate = GETDATE(), DeletedAt = GETDATE()"
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            result = query(connection, QUERY_FOR_ASSIGNMENT_EXCEPTIONS)

        assert result[0]['count'] == 0
    def it_should_return_zero(test_db_config: MssqlServerConfig):
        result = None
        # act
        run_harmonizer(test_db_config)
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            result = query(connection, QUERY_FOR_ASSIGNMENT_SUBMISSION_EXCEPTIONS)

        # assert - no errors
        result[0]['count'] == 0
    def it_should_update_existing_assignments(
            test_db_config: MssqlServerConfig, source_system: str,
            source_namespace: str):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_descriptor(connection,
                              descriptor_namespace_for(source_system),
                              ASSIGNMENT_CATEGORY)
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(connection,
                              descriptor_namespace_for(source_system),
                              source_system)
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_lms_section(connection, SIS_SECTION_ID, source_system)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute("""UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)""")

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                source_system,
                1,
                ASSIGNMENT_CATEGORY,
            )

        run_harmonizer(test_db_config)

        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            connection.execute(
                "UPDATE LMS.ASSIGNMENT SET TITLE = 'AN UPDATED TITLE', LastModifiedDate = GETDATE()"
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSAssignment = query(connection,
                                  "SELECT Title from [lmsx].[Assignment]")
            assert len(LMSAssignment) == 1
            assert LMSAssignment[0]["Title"] == "AN UPDATED TITLE"
Ejemplo n.º 15
0
    def it_should_return_no_exceptions(test_db_config: MssqlServerConfig):
        # act
        run_harmonizer(test_db_config)

        # Assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSUser")

            assert len(exceptions) == 0
Ejemplo n.º 16
0
    def it_should_return_exceptions(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID_1, "*****@*****.**", SOURCE_SYSTEM)
            insert_lms_user(connection, SIS_ID_2, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, "not_matching_sis_id_1")
            insert_edfi_student(connection, "not_matching_sis_id_2")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSUser")

            assert len(exceptions) == 2
            assert exceptions[0]["SourceSystemIdentifier"] == SIS_ID_1
            assert exceptions[1]["SourceSystemIdentifier"] == SIS_ID_2
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(
                connection,
                descriptor_namespace_for(UNKNOWN_SOURCE_SYSTEM),
                ASSIGNMENT_CATEGORY,
            )
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(
                connection,
                descriptor_namespace_for(UNKNOWN_SOURCE_SYSTEM),
                UNKNOWN_SOURCE_SYSTEM,
            )
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_lms_section(connection, SIS_SECTION_ID,
                               UNKNOWN_SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute("""UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)""")

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                UNKNOWN_SOURCE_SYSTEM,
                1,
                ASSIGNMENT_CATEGORY,
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSAssignment = query(connection,
                                  "SELECT * from [lmsx].[Assignment]")
            assert len(LMSAssignment) == 0
Ejemplo n.º 18
0
    def it_should_return_one_exception(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, UNIQUE_ID, STUDENT_ID)

            insert_lms_user(connection, NOT_MATCHING_SIS_ID, "*****@*****.**",
                            SOURCE_SYSTEM)
            insert_edfi_student(connection, "also_not_matching_unique_id")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            exceptions = query(
                connection,
                "SELECT SourceSystemIdentifier FROM lmsx.exceptions_LMSUser")

            assert len(exceptions) == 1
            assert exceptions[0][
                "SourceSystemIdentifier"] == NOT_MATCHING_SIS_ID
    def it_should_run_successfully(test_db_config: MssqlServerConfig):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_user(connection, SIS_ID, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, UNIQUE_ID, STUDENT_ID)

            insert_lms_user(connection, NOT_MATCHING_SIS_ID, "*****@*****.**", SOURCE_SYSTEM)
            insert_edfi_student(connection, "also_not_matching_unique_id")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSUser = query(
                connection,
                "SELECT EdFiStudentId, SourceSystemIdentifier from lms.LMSUser",
            )
            assert len(LMSUser) == 2
            assert LMSUser[0]["SourceSystemIdentifier"] == SIS_ID
            assert LMSUser[0]["EdFiStudentId"] == STUDENT_ID
            assert LMSUser[1]["SourceSystemIdentifier"] == NOT_MATCHING_SIS_ID
            assert LMSUser[1]["EdFiStudentId"] is None
    def it_should_run_successfully(test_db_config: MssqlServerConfig,
                                   source_system: str, source_namspace: str):
        section_id_1 = "sis_id_1"
        section_id_2 = "sis_id_2"

        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            insert_lms_section(connection, section_id_1, source_system)
            insert_lms_section(connection, section_id_2, source_system)
            insert_edfi_section(connection, "not_matching_sis_id_1")
            insert_edfi_section(connection, "not_matching_sis_id_2")

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSSection = query(
                connection,
                "SELECT AssignmentIdentifier from [lmsx].[Assignment]",
            )

            assert len(LMSSection) == 0
    def it_should_run_successfully(test_db_config: MssqlServerConfig,
                                   source_system: str, source_namespace: str):
        descriptor_namespace = descriptor_namespace_for(source_system)
        category_descriptor_id = 1
        source_system_descriptor_id = 2
        section_identifier = 1

        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(connection, descriptor_namespace,
                              ASSIGNMENT_CATEGORY)
            insert_lmsx_assignmentcategory_descriptor(connection,
                                                      category_descriptor_id)

            insert_descriptor(connection, descriptor_namespace, source_system)
            insert_lmsx_sourcesystem_descriptor(connection,
                                                source_system_descriptor_id)

            insert_lms_section(connection, SIS_SECTION_ID, source_system)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute("""UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)""")

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                source_system,
                section_identifier,
                ASSIGNMENT_CATEGORY,
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            result = query(connection, "SELECT * from [lmsx].[Assignment]")

        assert len(result) == 1, "There should be one result."

        LMSAssignment = result[0]

        assert (LMSAssignment["AssignmentIdentifier"] ==
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER
                ), "It should map the assignment identifier"

        # We know the id of the descriptors based in the order how they are inserted.
        assert (int(LMSAssignment["LMSSourceSystemDescriptorId"]) ==
                source_system_descriptor_id
                ), "It should map the SourceSystem descriptor"

        assert (int(LMSAssignment["AssignmentCategoryDescriptorId"]) ==
                category_descriptor_id
                ), "It should map the assignment category descriptor"

        assert (LMSAssignment["SectionIdentifier"] == SIS_SECTION_ID
                ), "It should map the section identifier"

        assert (LMSAssignment["LocalCourseCode"] == COURSE_CODE
                ), "It should map the local course code"

        assert (LMSAssignment["SessionName"] == SESSION_NAME
                ), "It should map the SessionName"

        assert (int(LMSAssignment["SchoolYear"]) == SCHOOL_YEAR
                ), "It should map the SchoolYear"

        assert int(LMSAssignment["SchoolId"]
                   ) == SCHOOL_ID, "It should map the SchoolId"

        assert (LMSAssignment["Namespace"] == source_namespace
                ), "It should map the Namespace"
    def it_should_insert_the_submissions_successfully(
        test_db_config: MssqlServerConfig, source_system: str
    ):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(
                connection, descriptor_namespace_for(source_system), ASSIGNMENT_CATEGORY
            )
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(
                connection, descriptor_namespace_for(source_system), source_system
            )
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_descriptor(
                connection,
                submission_descriptor_namespace_for(source_system),
                ASSIGNMENT_SUBMISSION_STATUS,
            )
            insert_lmsx_assignmentsubmissionstatus_descriptor(connection, 3)

            insert_lms_section(connection, SIS_SECTION_ID, source_system)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute(
                """UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)"""
            )

            assignment_id = insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                source_system,
                1,
                ASSIGNMENT_CATEGORY,
            )

            insert_lms_user(connection, USER_SIS_ID, USER_TEST_EMAIL, source_system)
            insert_edfi_student(connection, USER_SIS_ID)
            connection.execute(
                """UPDATE LMS.LMSUSER SET
                    EdFiStudentId = (SELECT TOP 1 ID FROM EDFI.Student)"""
            )

            insert_lms_assignment_submissions(
                connection,
                SUBMISSION_TEST_LMS_IDENTIFIER,
                SUBMISSION_TEST_IDENTIFIER,
                assignment_id,
                1,
                ASSIGNMENT_SUBMISSION_STATUS,
                source_system,
                False,
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSAssignmentSubmission = query(
                connection, "SELECT * from [lmsx].[AssignmentSubmission]"
            )

            assert len(LMSAssignmentSubmission) == 1
            assert (
                LMSAssignmentSubmission[0]["AssignmentSubmissionIdentifier"]
                == SUBMISSION_TEST_IDENTIFIER
            )
    def it_should_return_zero(
        test_db_config: MssqlServerConfig
    ):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(
                connection, descriptor_namespace_for(SOURCE_SYSTEM), ASSIGNMENT_CATEGORY
            )
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(
                connection, descriptor_namespace_for(SOURCE_SYSTEM), SOURCE_SYSTEM
            )
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_descriptor(
                connection,
                submission_descriptor_namespace_for(SOURCE_SYSTEM),
                ASSIGNMENT_SUBMISSION_STATUS,
            )
            insert_lmsx_assignmentsubmissionstatus_descriptor(connection, 3)

            insert_lms_section(connection, SIS_SECTION_ID, SOURCE_SYSTEM)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute(
                """UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)"""
            )

            assignment_id = insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                SOURCE_SYSTEM,
                1,
                ASSIGNMENT_CATEGORY,
            )

            insert_lms_user(connection, USER_SIS_ID, USER_TEST_EMAIL, SOURCE_SYSTEM)
            insert_edfi_student(connection, USER_SIS_ID)
            connection.execute(
                """UPDATE LMS.LMSUSER SET
                    EdFiStudentId = (SELECT TOP 1 ID FROM EDFI.Student)"""
            )

            insert_lms_assignment_submissions(
                connection,
                SUBMISSION_TEST_LMS_IDENTIFIER,
                SUBMISSION_TEST_IDENTIFIER,
                assignment_id,
                1,
                ASSIGNMENT_SUBMISSION_STATUS,
                SOURCE_SYSTEM,
                False,
            )

        # act
        result = None
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            result = query(connection, QUERY_FOR_ASSIGNMENT_SUBMISSION_EXCEPTIONS)

        result[0]['count'] == 0
    def it_should_create_missing_submissions_for_associated_students(
            test_db_config: MssqlServerConfig, source_system: str):
        # arrange
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:

            insert_descriptor(
                connection, descriptor_namespace_for(source_system), ASSIGNMENT_CATEGORY
            )
            insert_lmsx_assignmentcategory_descriptor(connection, 1)

            insert_descriptor(
                connection, descriptor_namespace_for(source_system), source_system
            )
            insert_lmsx_sourcesystem_descriptor(connection, 2)

            insert_descriptor(
                connection,
                submission_descriptor_namespace_for(source_system),
                ASSIGNMENT_SUBMISSION_STATUS_MISSING,
            )
            insert_lmsx_assignmentsubmissionstatus_descriptor(connection, 3)

            insert_descriptor(
                connection,
                submission_descriptor_namespace_for(source_system),
                ASSIGNMENT_SUBMISSION_STATUS_UPCOMING,
            )
            insert_lmsx_assignmentsubmissionstatus_descriptor(connection, 4)

            insert_lms_section(connection, SIS_SECTION_ID, source_system)
            insert_edfi_section(connection, SIS_SECTION_ID)
            connection.execute(
                """UPDATE LMS.LMSSECTION SET
                    EdFiSectionId = (SELECT TOP 1 ID FROM EDFI.SECTION)"""
            )

            insert_lms_assignment(
                connection,
                ASSIGNMENT_SOURCE_SYSTEM_IDENTIFIER,
                source_system,
                1,
                ASSIGNMENT_CATEGORY
            )

            insert_lms_user(connection, USER_SIS_ID, USER_TEST_EMAIL, source_system)
            insert_edfi_student(connection, USER_SIS_ID)
            connection.execute(
                """UPDATE LMS.LMSUSER SET
                    EdFiStudentId = (SELECT TOP 1 ID FROM EDFI.Student)"""
            )
            insert_edfi_section_association(
                connection,
                SIS_SECTION_ID,
                USER_SIS_ID
            )

        # act
        run_harmonizer(test_db_config)

        # assert
        with MSSqlConnection(test_db_config).pyodbc_conn() as connection:
            LMSAssignmentSubmission = query(
                connection, "SELECT * from [lmsx].[AssignmentSubmission]"
            )
            # We are only creating records for Schoology
            if (source_system == SOURCE_SYSTEM.SCHOOLOGY):
                assert len(LMSAssignmentSubmission) == 1
            else:
                assert len(LMSAssignmentSubmission) == 0