def it_should_not_soft_delete_record_from_different_source_system( test_pgsql_db: Tuple[SqlLmsOperations, Connection, ConnectionSettings]): operations_adapter, connection, settings = test_pgsql_db # arrange - note csv file has only B123456 from BestLMS. F234567 is from # a different source system. Although it is missing from the file, it # should not be soft deleted. insert_user(connection, "B123456", SOURCE_SYSTEM, 99898) insert_user(connection, "F234567", "FirstLMS", 99899) # act run_loader(main_arguments(operations_adapter, CSV_PATH, settings)) # assert - records are unchanged LMSUser = connection.execute( "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmsuser order by sourcesystemidentifier" ).fetchall() assert len(LMSUser) == 2 def get_user(source_system: str) -> dict: query = [x for x in LMSUser if x["sourcesystem"] == source_system] assert len(query) == 1, f"No record returned for {source_system}" return query[0] first = get_user("FirstLMS") assert "F234567" == first[ "sourcesystemidentifier"], "First sourcesystemidentifier" assert first["deletedat"] is None, "First deletedat" first = get_user(SOURCE_SYSTEM) assert "B123456" == first[ "sourcesystemidentifier"], "Best sourcesystemidentifier" assert first["deletedat"] is None, "Best deletedat"
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_user(connection, "U123456", SOURCE_SYSTEM, 1) insert_record(connection, "B123456", SOURCE_SYSTEM) insert_record(connection, "F234567", "FirstLMS") # act run_loader(main_arguments(adapter, CSV_PATH, settings)) # assert - records are unchanged LMSSystemActivity = connection.execute( "select sourcesystem, sourcesystemidentifier, deletedat from lms.lmssystemactivity order by sourcesystemidentifier" ).fetchall() assert len(LMSSystemActivity) == 2 assert [SOURCE_SYSTEM, "FirstLMS"] == [ x["sourcesystem"] for x in LMSSystemActivity ] assert ["B123456", "F234567"] == [ x["sourcesystemidentifier"] for x in LMSSystemActivity ] assert [None, None] == [x["deletedat"] for x in LMSSystemActivity]
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 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]
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]): operations_adapter, connection, settings = test_pgsql_db # arrange - note csv file has only B123456 insert_user(connection, "B123456", SOURCE_SYSTEM, 9998) insert_user(connection, "B234567", SOURCE_SYSTEM, 9999) # act run_loader(main_arguments(operations_adapter, CSV_PATH, settings)) # assert - B234567 has been soft deleted LMSUser = connection.execute( "select sourcesystemidentifier from lms.lmsuser where deletedat is not null" ).fetchall() assert len(LMSUser) == 1 assert LMSUser[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_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"