def it_should_match_the_record(test_mssql_db: Tuple[SqlLmsOperations, Connection]):
        adapter, connection = test_mssql_db
        insert_user(connection, "U123456", SOURCE_SYSTEM, 1)
        insert_user(connection, "U123456", "FirstLMS", 2)

        insert_section(connection, "S098765", SOURCE_SYSTEM, 1)
        insert_section(connection, "S098765", "FirstLMS", 2)

        insert_assignment(connection, "B098765", SOURCE_SYSTEM, 1, 1)
        insert_assignment(connection, "F098765", SOURCE_SYSTEM, 2, 2)

        insert_record(connection, "B123456", SOURCE_SYSTEM, 1, 1)
        insert_record(connection, "F234567", "FirstLMS", 2, 2)

        # act
        run_loader(main_arguments(adapter, CSV_PATH))

        # assert - records are unchanged
        AssignmentSubmission = connection.execute(
            "SELECT SourceSystem, SourceSystemIdentifier, DeletedAt from lms.AssignmentSubmission"
        ).fetchall()
        assert len(AssignmentSubmission) == 2
        assert [SOURCE_SYSTEM, "FirstLMS"] == [
            x["SourceSystem"] for x in AssignmentSubmission
        ]
        assert ["B123456", "F234567"] == [
            x["SourceSystemIdentifier"] for x in AssignmentSubmission
        ]
        assert [None, None] == [x["DeletedAt"] for x in AssignmentSubmission]
Exemplo n.º 2
0
    def it_should_match_the_record(test_mssql_db: Tuple[SqlLmsOperations,
                                                        Connection]):
        adapter, connection = test_mssql_db
        insert_user(connection, "U123456", SOURCE_SYSTEM, 1)

        insert_section(connection, "B098765", SOURCE_SYSTEM, 1)
        insert_section(connection, "B109876", SOURCE_SYSTEM, 2)

        insert_user_section_association(connection, "UB098765", SOURCE_SYSTEM,
                                        1, 1, 1)
        insert_user_section_association(connection, "UF109876", SOURCE_SYSTEM,
                                        2, 1, 2)

        insert_record(connection, "B123456", SOURCE_SYSTEM, 1, 1, 1)
        insert_record(connection, "B234567", SOURCE_SYSTEM, 2, 1, 2)

        # act
        run_loader(main_arguments(adapter, CSV_PATH))

        # assert - records are unchanged
        LMSUserAttendanceEvent = connection.execute(
            "SELECT SourceSystem, SourceSystemIdentifier, DeletedAt from lms.LMSUserAttendanceEvent"
        ).fetchall()
        assert len(LMSUserAttendanceEvent) == 2
        assert [SOURCE_SYSTEM, SOURCE_SYSTEM
                ] == [x["SourceSystem"] for x in LMSUserAttendanceEvent]
        assert ["B123456", "B234567"] == [
            x["SourceSystemIdentifier"] for x in LMSUserAttendanceEvent
        ]
        assert [None, None] == [x["DeletedAt"] for x in LMSUserAttendanceEvent]
    def it_should_soft_delete_the_record(test_mssql_db: Tuple[SqlLmsOperations,
                                                              Connection]):
        adapter, connection = test_mssql_db

        # arrange - note csv file has only B123456
        insert_section(connection, "B098765", SOURCE_SYSTEM, 1)
        insert_record(connection, "B123456", SOURCE_SYSTEM, 1)
        insert_record(connection, "B234567", SOURCE_SYSTEM, 1)

        # act
        run_loader(main_arguments(adapter, CSV_PATH))

        # assert - B234567 has been soft deleted
        Assignment = connection.execute(
            "SELECT SourceSystemIdentifier from lms.Assignment WHERE DeletedAt IS NOT NULL"
        ).fetchall()
        assert len(Assignment) == 1
        assert Assignment[0]["SourceSystemIdentifier"] == "B234567"