Exemplo n.º 1
0
def sis_api_profiles(app, student_tables):
    from nessie.externals import redshift
    from nessie.jobs.import_sis_student_api import ImportSisStudentApi
    with mock_s3(app):
        ImportSisStudentApi().run_wrapped()
    sql = """SELECT sid, feed FROM student_test.sis_api_profiles"""
    return redshift.fetch(sql)
Exemplo n.º 2
0
def analyze_student(sid):
    _safety_check()
    result = {}

    for key in ('edl', 'sis'):
        with _override_edl_feature_flag(key == 'edl'):
            rows, failure_count = ImportSisStudentApi().load(all_sids=[sid])
            result[key] = {
                'failureCount': failure_count,
                'rows': rows,
            }
    return tolerant_jsonify(result)
Exemplo n.º 3
0
 def test_import_sis_student_api_v1(self, app, metadata_db, student_tables, caplog):
     from nessie.jobs.import_sis_student_api import ImportSisStudentApi
     with override_config(app, 'STUDENT_V1_API_PREFERRED', True):
         with mock_s3(app):
             result = ImportSisStudentApi().run_wrapped()
         assert result == 'SIS student API V1 import job completed: 4 succeeded, 6 failed.'
         rows = redshift.fetch('SELECT * FROM student_test.sis_api_profiles_v1 ORDER BY sid')
         assert len(rows) == 4
         assert rows[0]['sid'] == '11667051'
         assert rows[1]['sid'] == '1234567890'
         assert rows[2]['sid'] == '2345678901'
         assert rows[3]['sid'] == '5000000000'
         feed = json.loads(rows[0]['feed'], strict=False)
         assert feed['names'][0]['familyName'] == 'Bear'
Exemplo n.º 4
0
 def test_import_sis_student_api(self, app, metadata_db, student_tables,
                                 caplog):
     from nessie.jobs.import_sis_student_api import ImportSisStudentApi
     with mock_s3(app):
         result = ImportSisStudentApi().run_wrapped()
     assert result == 'SIS student API import job completed: 2 succeeded, 6 failed.'
     rows = redshift.fetch(
         'SELECT * FROM student_test.sis_api_profiles ORDER BY sid')
     print(rows)
     assert len(rows) == 2
     assert rows[0]['sid'] == '11667051'
     assert rows[1]['sid'] == '2345678901'
     feed = json.loads(rows[0]['feed'], strict=False)
     assert feed['names'][0]['familyName'] == 'Bear'
Exemplo n.º 5
0
 def test_import_sis_student_api(self, app, metadata_db, student_tables, caplog):
     from nessie.jobs.import_sis_student_api import ImportSisStudentApi
     initial_rows = redshift.fetch('SELECT * FROM student_test.sis_api_profiles ORDER BY sid')
     assert len(initial_rows) == 0
     with mock_s3(app):
         result = ImportSisStudentApi().run_wrapped()
     assert result == 'SIS student API import job completed: 3 succeeded, 7 failed.'
     rows = redshift.fetch('SELECT * FROM student_test.sis_api_profiles ORDER BY sid')
     assert len(rows) == 3
     assert rows[0]['sid'] == '11667051'
     feed = json.loads(rows[0]['feed'], strict=False)
     assert feed['names'][0]['familyName'] == 'Bear'
     assert feed['registrations'][0]['term']['id'] == '2178'
     assert rows[1]['sid'] == '1234567890'
     feed = json.loads(rows[1]['feed'], strict=False)
     # Needed to test proper sis_profile merging of last_registrations table.
     assert not feed.get('registrations')
     assert rows[2]['sid'] == '2345678901'
     feed = json.loads(rows[2]['feed'], strict=False)
     assert feed['registrations'][0]['term']['id'] == '2178'
Exemplo n.º 6
0
def import_sis_student_api():
    job_started = ImportSisStudentApi().run_async()
    return respond_with_status(job_started)