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

        insert_section(connection, "B098765", SOURCE_SYSTEM, 1)
        insert_section(connection, "F098765", "FirstLMS", 2)

        insert_user_section_association(connection, "UB123456", SOURCE_SYSTEM,
                                        1, 1, 1)
        insert_user_section_association(connection, "UF123456", SOURCE_SYSTEM,
                                        2, 2, 2)

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

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        LMSUserAttendanceEvent = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmsuserattendanceevent order by sourcesystemidentifier"
        ).fetchall()
        assert len(LMSUserAttendanceEvent) == 2
        assert [SOURCE_SYSTEM, "FirstLMS"
                ] == [x["sourcesystem"] for x in LMSUserAttendanceEvent]
        assert ["B123456", "F234567"] == [
            x["sourcesystemidentifier"] for x in LMSUserAttendanceEvent
        ]
        assert [None, None] == [x["deletedat"] for x in LMSUserAttendanceEvent]
Exemplo n.º 2
0
    def it_should_match_the_record(test_pgsql_db: Tuple[SqlLmsOperations,
                                                        Connection,
                                                        ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        section_identifier_1 = 13
        insert_section(connection, "B098765", SOURCE_SYSTEM,
                       section_identifier_1)
        section_identifier_2 = 14
        insert_section(connection, "B109876", SOURCE_SYSTEM,
                       section_identifier_2)

        insert_assignment(connection, "B123456", SOURCE_SYSTEM, 11,
                          section_identifier_1)
        insert_assignment(connection, "B234567", SOURCE_SYSTEM, 12,
                          section_identifier_2)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        Assignment = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.assignment order by sourcesystemidentifier"
        ).fetchall()
        assert len(Assignment) == 2
        assert [SOURCE_SYSTEM,
                SOURCE_SYSTEM] == [x["sourcesystem"] for x in Assignment]
        assert ["B123456", "B234567"
                ] == [x["sourcesystemidentifier"] for x in Assignment]
        assert [None, None] == [x["deletedat"] for x in Assignment]
    def it_should_soft_delete_the_record(
        test_pgsql_db: Tuple[SqlLmsOperations, Connection,
                             ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        # arrange - note csv file has only B123456
        user_identifier = 13
        insert_user(connection, "U123456", SOURCE_SYSTEM, user_identifier)

        section_identifier = 14
        insert_section(connection, "S098765", SOURCE_SYSTEM,
                       section_identifier)

        assignment_identifier = 15
        insert_assignment(connection, "B098765", SOURCE_SYSTEM,
                          assignment_identifier, section_identifier)

        insert_record(connection, "B123456", SOURCE_SYSTEM,
                      assignment_identifier, user_identifier)
        insert_record(connection, "B234567", SOURCE_SYSTEM,
                      assignment_identifier, user_identifier)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - B234567 has been soft deleted
        AssignmentSubmission = connection.execute(
            "select sourcesystemidentifier from lms.assignmentsubmission where deletedat is not null"
        ).fetchall()
        assert len(AssignmentSubmission) == 1
        assert AssignmentSubmission[0]["sourcesystemidentifier"] == "B234567"
    def it_should_match_the_record(
        test_pgsql_db: Tuple[SqlLmsOperations, Connection, ConnectionSettings]
    ):
        adapter, connection, settings = test_pgsql_db
        user_identifier = 10
        insert_user(connection, "U123456", SOURCE_SYSTEM, user_identifier)

        section_identifier_1 = 11
        insert_section(connection, "B098765", SOURCE_SYSTEM, section_identifier_1)
        section_identifier_2 = 12
        insert_section(connection, "B109876", SOURCE_SYSTEM, section_identifier_2)

        insert_user_section_association(connection, "B123456", SOURCE_SYSTEM, 11, user_identifier, section_identifier_1)
        insert_user_section_association(connection, "B234567", SOURCE_SYSTEM, 12, user_identifier, section_identifier_2)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        LMSUserLMSSectionAssociation = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmsuserlmssectionassociation order by sourcesystemidentifier"
        ).fetchall()
        assert len(LMSUserLMSSectionAssociation) == 2
        assert [SOURCE_SYSTEM, SOURCE_SYSTEM] == [
            x["sourcesystem"] for x in LMSUserLMSSectionAssociation
        ]
        assert ["B123456", "B234567"] == [
            x["sourcesystemidentifier"] for x in LMSUserLMSSectionAssociation
        ]
        assert [None, None] == [x["deletedat"] for x in LMSUserLMSSectionAssociation]
    def it_should_match_the_record(test_pgsql_db: Tuple[SqlLmsOperations,
                                                        Connection,
                                                        ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db
        insert_user(connection, "U123456", SOURCE_SYSTEM, 1)

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

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

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        LMSSectionActivity = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmssectionactivity order by sourcesystemidentifier"
        ).fetchall()
        assert len(LMSSectionActivity) == 2
        assert [SOURCE_SYSTEM, SOURCE_SYSTEM
                ] == [x["sourcesystem"] for x in LMSSectionActivity]
        assert ["B123456", "B234567"
                ] == [x["sourcesystemidentifier"] for x in LMSSectionActivity]
        assert [None, None] == [x["deletedat"] for x in LMSSectionActivity]
    def it_should_soft_delete_the_record(
        test_pgsql_db: Tuple[SqlLmsOperations, Connection,
                             ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        # arrange - note csv file has only B123456
        insert_section(connection, "B123456", SOURCE_SYSTEM, 99988)
        insert_section(connection, "B234567", SOURCE_SYSTEM, 99989)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - B234567 has been soft deleted
        LMSSection = connection.execute(
            "select sourcesystemidentifier from lms.lmssection where deletedat is not null"
        ).fetchall()
        assert len(LMSSection) == 1
        assert LMSSection[0]["sourcesystemidentifier"] == "B234567"
    def it_should_match_the_record(test_pgsql_db: Tuple[SqlLmsOperations,
                                                        Connection,
                                                        ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        user_identifier = 11
        insert_user(connection, "U123456", SOURCE_SYSTEM, user_identifier)
        user_identifier = 12
        insert_user(connection, "U123456", "FirstLMS", user_identifier)

        section_identifier = 13
        insert_section(connection, "S098765", SOURCE_SYSTEM,
                       section_identifier)
        section_identifier = 14
        insert_section(connection, "S098765", "FirstLMS", section_identifier)

        assignment_identifier_1 = 15
        insert_assignment(connection, "B098765", SOURCE_SYSTEM,
                          assignment_identifier_1, section_identifier)
        assignment_identifier_2 = 16
        insert_assignment(connection, "F098765", SOURCE_SYSTEM,
                          assignment_identifier_2, section_identifier)

        insert_record(connection, "B123456", SOURCE_SYSTEM,
                      assignment_identifier_1, user_identifier)
        insert_record(connection, "F234567", "FirstLMS",
                      assignment_identifier_2, user_identifier)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        AssignmentSubmission = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.assignmentsubmission order by sourcesystemidentifier"
        ).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]
    def it_should_match_the_record(test_pgsql_db: Tuple[SqlLmsOperations,
                                                        Connection,
                                                        ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        # arrange - note csv file has only B123456 from BestLMS
        insert_section(connection, "B123456", SOURCE_SYSTEM, 99998)
        insert_section(connection, "F234567", "FirstLMS", 99999)

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - records are unchanged
        LMSSection = connection.execute(
            "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmssection order by sourcesystemidentifier"
        ).fetchall()
        assert len(LMSSection) == 2
        assert [SOURCE_SYSTEM,
                "FirstLMS"] == [x["sourcesystem"] for x in LMSSection]
        assert ["B123456", "F234567"
                ] == [x["sourcesystemidentifier"] for x in LMSSection]
        assert [None, None] == [x["deletedat"] for x in LMSSection]
    def it_should_soft_delete_the_record(
        test_pgsql_db: Tuple[SqlLmsOperations, Connection,
                             ConnectionSettings]):
        adapter, connection, settings = test_pgsql_db

        # arrange - note csv file has only B123456
        insert_user(connection, "U123456", SOURCE_SYSTEM, 1)
        insert_section(connection, "B098765", SOURCE_SYSTEM, 1)
        insert_user_section_association(connection, "UB123456", SOURCE_SYSTEM,
                                        1, 1, 1)

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

        # act
        run_loader(main_arguments(adapter, CSV_PATH, settings))

        # assert - B234567 has been soft deleted
        LMSUserAttendanceEvent = connection.execute(
            "select sourcesystemidentifier from lms.lmsuserattendanceevent where deletedat is not null"
        ).fetchall()
        assert len(LMSUserAttendanceEvent) == 1
        assert LMSUserAttendanceEvent[0]["sourcesystemidentifier"] == "B234567"