def test_srjc_ucla(): with open(TEST_FILE_PATH + "SRC_to_UCLA.json") as f: ucla = json.load(f) frontend_obj = matgen.generate_matrix([ucla]) with open(OUTPUT_FILE_PATH + 'srjc-ucla-out.json', 'w') as fp: json.dump(frontend_obj, fp) pprint.pprint(frontend_obj)
def test_srjc_ssu(): with open(TEST_FILE_PATH + "SRC_to_SSU.json") as f: ssu = json.load(f) frontend_obj = matgen.generate_matrix([ssu]) with open(OUTPUT_FILE_PATH + 'srjc-ssu-out.json', 'w') as fp: json.dump(frontend_obj, fp) pprint.pprint(frontend_obj)
def test_generate_matrix_single_agreement(): with open(TEST_FILE_PATH + "test1/dbformat.json") as f: test1_db = json.load(f) with open(TEST_FILE_PATH + "test1/frontend-ready.json") as f: test1_frontend = json.load(f) frontend_obj = matgen.generate_matrix([test1_db]) pprint.pprint(frontend_obj) assert_lookup_equal(frontend_obj['lookup'], test1_frontend['lookup']) # TODO: Write helper function to check if equivalency matrix is equal, ignoring order of rows, # but maintaining unit/class groupings and AND/OR row relationships. assert frontend_obj['equivalencyMatrix'] == test1_frontend[ 'equivalencyMatrix']
def test_generate_matrix_three_agreements(): with open(TEST_FILE_PATH + "test2/school1-db.json") as f: school1 = json.load(f) with open(TEST_FILE_PATH + "test2/school2-db.json") as f: school2 = json.load(f) with open(TEST_FILE_PATH + "test2/school3-db.json") as f: school3 = json.load(f) with open(TEST_FILE_PATH + "test2/frontend-ready.json") as f: frontend_ready = json.load(f) frontend_obj = matgen.generate_matrix([school1, school2, school3]) pprint.pprint(frontend_obj) assert_lookup_equal(frontend_obj['lookup'], frontend_ready['lookup']) assert frontend_obj['equivalencyMatrix'] == frontend_ready[ 'equivalencyMatrix']
def test_all_three(): with open(TEST_FILE_PATH + "SRC_to_SJSU.json") as f: sjsu = json.load(f) with open(TEST_FILE_PATH + "SRC_to_SSU.json") as f: ssu = json.load(f) with open(TEST_FILE_PATH + "SRC_to_UCLA.json") as f: ucla = json.load(f) frontend_obj = matgen.generate_matrix([sjsu, ssu, ucla]) with open(OUTPUT_FILE_PATH + 'combined-out.json', 'w') as fp: json.dump(frontend_obj, fp) pprint.pprint(frontend_obj) # ## Uncomment this if you want to see the output on pytest # assert False
def test_generate_matrix_rel2next(): with open(TEST_FILE_PATH + "test3/school1-db.json") as f: school1 = json.load(f) with open(TEST_FILE_PATH + "test3/school2-db.json") as f: school2 = json.load(f) with open(TEST_FILE_PATH + "test3/school3-db.json") as f: school3 = json.load(f) with open(TEST_FILE_PATH + "test3/frontend-ready.json") as f: frontend_ready = json.load(f) frontend_obj = matgen.generate_matrix([school1, school2, school3]) # pprint.pprint(frontend_obj) print("expected matrix:") pprint.pprint(frontend_ready['equivalencyMatrix']) print("actual matrix:") pprint.pprint(frontend_obj['equivalencyMatrix']) assert_lookup_equal(frontend_obj['lookup'], frontend_ready['lookup']) assert frontend_obj['equivalencyMatrix'] == frontend_ready[ 'equivalencyMatrix']
def agreements(): app.logger.info(request.args.to_dict()) num = int(request.args.get('num')) ids = [] for x in range(0, num): ids.append(request.args.get('id' + str(x))) app.logger.info("the IDs are") app.logger.info(ids) agreement_jsons = [] for x in range(0, num): #app.logger.info(db.get_agreement( ids[x] )) agreement_jsons.append(json.loads(db.get_agreement(ids[x]))) ##pprint.pprint(agreement_jsons) finalMatrix = matrix_generator.generate_matrix(agreement_jsons) pprint.pprint(finalMatrix) return finalMatrix