class Test(unittest.TestCase):

    def setUp(self):
        self.ctq = CourseTableQuery({}, 20)
        self.ctq.connect()
        self.ctq.set_cursor(self.ctq.course_query.get_courses_cursor_subject(subject_code))
        
    def tearDown(self):
        self.ctq.disconnect()

    def test1(self):
        jsonlist = self.ctq.get_table_page_JSON_list(1)
        self.assertEqual(len(jsonlist), 20)
        for json in jsonlist:
            self.assertEqual(json['code'], 'CS')
        
    def test2(self):
        cursor1 = self.ctq.get_table_page_cursor(1)
        cq = CourseQuery()
        cq.connect()
        cursor2 = cq.get_courses_cursor_subject(subject_code)
        cq.disconnect()
        list1 = []
        for x in cursor1:
            list1.append(x)
        self.assertEqual(len(list1), 20)
        list2 = []
        for x in cursor2:
            list2.append(x)
        for a,b in zip(list1,list2):
            self.assertEqual(a,b)
 section_query = SectionQuery()
 section_query.connect()
 print(section_query.get_cursor({})[0])
 print(section_query.client[section_query.db_name][section_query.collection_name].distinct('days_of_week'))
 print('HERE')
 section_query.disconnect()
 
 prof_query = ProfQuery()
 prof_query.connect()
 print(prof_query.get_cursor({})[0])
 prof_query.disconnect()
 
 table_query = CourseTableQuery({}, 20)
 table_query.connect()
 print(table_query.get_table_page_JSON_list(1))
 table_query.disconnect()
 
 course_query = CourseQuery()
 course_query.connect()
 print(course_query.client[course_query.db_name][course_query.collection_name])
 print(sorted(course_query.client[course_query.db_name][course_query.collection_name].distinct('code')))
 print(course_query.get_course_JSON('CS', '125'))
 print(course_query.get_subject_codes())
 print(course_query.get_course_ids_for_subject('CS'))
 #print(course_query.get_course_ids_all_subjects())
 course_query.disconnect()
 
 course_query.connect()
 print(course_query.search_for_course_cursor(min_gpa = 3)[0])
 print(course_query.get_credit_hour_list())