def it_should_run_successfully(test_db_config: PgsqlServerConfig): SIS_ID_1 = "c_sis_id_1" SIS_ID_2 = "c_sis_id_2" # arrange with PgsqlConnection(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, "c_not_matching_sis_id_1") insert_edfi_student(connection, "c_not_matching_sis_id_2") # act run_harmonizer(test_db_config) # assert with PgsqlConnection(test_db_config).pyodbc_conn() as connection: LMSUser = query( connection, f"select edfistudentid from lms.lmsuser where sourcesystemidentifier in ('{SIS_ID_1}','{SIS_ID_2}')", ) assert len(LMSUser) == 2 assert LMSUser[0]["edfistudentid"] is None assert LMSUser[1]["edfistudentid"] is None
def it_should_run_successfully(test_db_config: PgsqlServerConfig): # arrange with PgsqlConnection(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, "c_also_not_matching_unique_id") # act run_harmonizer(test_db_config) # assert with PgsqlConnection(test_db_config).pyodbc_conn() as connection: LMSUser = query( connection, (f"select edfistudentid, sourcesystemidentifier from lms.lmsuser where " f"sourcesystemidentifier in ('{NOT_MATCHING_SIS_ID}','{SIS_ID}')" ), ) assert len(LMSUser) == 2 assert LMSUser[0][ "sourcesystemidentifier"] == NOT_MATCHING_SIS_ID assert LMSUser[0]["edfistudentid"] is None assert LMSUser[1]["sourcesystemidentifier"] == SIS_ID assert LMSUser[1]["edfistudentid"] == STUDENT_ID
def it_should_create_missing_submissions_for_associated_students( test_db_config: PgsqlServerConfig, source_system: str): # arrange with PgsqlConnection(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 id from edfi.section limit 1)""") 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 id from edfi.student limit 1)""") insert_edfi_section_association(connection, SIS_SECTION_ID, USER_SIS_ID) # act run_harmonizer(test_db_config) # assert with PgsqlConnection(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
def it_should_return_no_exceptions(test_db_config: PgsqlServerConfig): # arrange with PgsqlConnection(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 PgsqlConnection(test_db_config).pyodbc_conn() as connection: exceptions = query( connection, f"select sourcesystemidentifier from lmsx.exceptions_lmsuser where sourcesystemidentifier = '{SIS_ID}'" ) assert len(exceptions) == 0
def it_should_run_successfully(test_db_config: PgsqlServerConfig): # arrange with PgsqlConnection(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 PgsqlConnection(test_db_config).pyodbc_conn() as connection: LMSUser = query( connection, f"select edfistudentid from lms.lmsuser where sourcesystemidentifier='{SIS_ID}'", ) assert len(LMSUser) == 1 assert LMSUser[0]["edfistudentid"] == STUDENT_ID
def it_should_return_exceptions(test_db_config: PgsqlServerConfig): # arrange with PgsqlConnection(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, "v+not_matching_sis_id_1") insert_edfi_student(connection, "v+not_matching_sis_id_2") # act run_harmonizer(test_db_config) # assert with PgsqlConnection(test_db_config).pyodbc_conn() as connection: exceptions = query( connection, f"select sourcesystemidentifier from lmsx.exceptions_lmsuser where sourcesystemidentifier in ('{SIS_ID_1}', '{SIS_ID_2}')" ) assert len(exceptions) == 2 assert exceptions[0]["sourcesystemidentifier"] == SIS_ID_1 assert exceptions[1]["sourcesystemidentifier"] == SIS_ID_2
def it_should_return_one_exception(test_db_config: PgsqlServerConfig): # arrange with PgsqlConnection(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, "v+also_not_matching_unique_id") # act run_harmonizer(test_db_config) # assert with PgsqlConnection(test_db_config).pyodbc_conn() as connection: exceptions = query( connection, f"select sourcesystemidentifier from lmsx.exceptions_lmsuser where sourcesystemidentifier = '{NOT_MATCHING_SIS_ID}'" ) assert len(exceptions) == 1 assert exceptions[0][ "sourcesystemidentifier"] == NOT_MATCHING_SIS_ID
def it_should_insert_the_submissions_successfully( test_db_config: PgsqlServerConfig, source_system: str): # arrange with PgsqlConnection(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 id from edfi.section limit 1)""") 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 id from edfi.student limit 1)""") 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 PgsqlConnection(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: PgsqlServerConfig): # arrange with PgsqlConnection(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 id from edfi.section limit 1)""") 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 id from edfi.student limit 1)""") 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 PgsqlConnection(test_db_config).pyodbc_conn() as connection: result = query(connection, QUERY_FOR_ASSIGNMENT_SUBMISSION_EXCEPTIONS) result[0]['count'] == 0