Beispiel #1
0
    def test_initialize(self, bot):
        assert bot.form_data is not None, 'Form data is not initialized'
        assert bot.html is not None, 'Html is not fetched'

        macro = searchbot(init=False)
        assert macro.form_data is None, 'Should be not initialized'
        assert macro.html is None, 'Should be not initialized'
Beispiel #2
0
 def waiting(self, semester, year, crns, alarm, rate):
     from lib.animation import load_animation, countdown
     from lib.searchbot import searchbot
     bot = searchbot(init=False)
     bot.setData(year=year, term=semester)
     changes = [self.notifychange(-1, alarm_) for alarm_ in alarm]
     while True:
         t_ = int(rate) * 60
         result = ""
         print("Press Ctrl-C to quit")
         animation = load_animation("Fetching requested classes information", clear_at_end=False)
         timer = countdown(t_)
         animation.start()
         seats, result = self.printresult(year, semester, crns)
         for seat, change, option in zip(seats, changes, alarm):
             if change is not None:
                 change = change(int(seat))
             else:
                 change = self.notifychange(seat, option)
         animation.end = True
         time.sleep(1)
         print(result)
         timer.start()
         while(t_):
             time.sleep(1)
             t_ -= 1
Beispiel #3
0
 def save(self, semester, year, file_name):
     from lib.animation import load_animation
     from lib.searchbot import searchbot
     self.animation = load_animation("Fetching html file", clear_at_end=False)
     self.animation.start()
     loc = searchbot(year=year, term=semester).saveHtml(file_name=file_name)    
     self.animation.end = True
     time.sleep(1)
     result = "Successfully Saved to " + loc
     print(result)
     return result
Beispiel #4
0
    def test_setdata_name(self):
        macro = searchbot(init=False)
        macro.setData(year=2025, term="sPrInG")
        assert macro.form_data[0][1] == '202530', 'Wrong Form Data'

        macro.setData(year=2008, term="wInTeR  ")
        assert macro.form_data[0][1] == '200810', 'Wrong Form Data'

        macro.setData(year=2010, term="  fAlL  ")
        assert macro.form_data[0][1] == '201070', 'Wrong Form Data'

        macro.setData(year=2001, term="      sumMeR")
        assert macro.form_data[0][1] == '200150', 'Wrong Form Data'
Beispiel #5
0
 def printresult(self, year, semester, crns):
     from lib.searchbot import searchbot
     bot = searchbot(year=year, term=semester)
     seats = []
     result = ""
     for crn in crns:
         bot.getTable(crn)
         class_ = bot.getClass()
         seat = bot.getSeats()
         prof = bot.getProf()
         result += f"Class: {class_}\tProfessor: {prof}\tSeats: {seat}\n"
         seats.append(seat)
     return seats, result
Beispiel #6
0
 def test_setdata_json(self, file_name="testjson.json"):
     macro = searchbot(init=False)
     macro.setData(9999, 'Winter', "/tests/data/" + file_name)
     test_form_data = [
         ['TERM', '999910'],
         ['TERM_DESC', 'Winter 9999'],
         ['sel_subj', 'dummy'],
         ['sel_subj', '%'],
         ['sel_day', 'dummy'],
         ['sel_schd', 'dummy'],
         ['sel_schd', '%'],
         ['sel_camp', 'dummy'],
         ['sel_camp', '%'],
         ['sel_ism', 'dummy'],
         ['sel_ism', '%'],
         ['sel_sess', 'dummy'],
         ['sel_sess', '%'],
         ['sel_instr', 'dummy'],
         ['sel_instr', '%'],
         ['sel_ptrm', 'dummy'],
         ['sel_ptrm', '%'],
         ['sel_attrib', 'dummy'],
         ['sel_attrib', '%'],
         ['sel_crse', ''],
         ['sel_crn', ''],
         ['sel_title', ''],
         ['begin_hh', '5'],
         ['begin_mi', '0'],
         ['begin_ap', 'a'],
         ['end_hh', '11'],
         ['end_mi', '0'],
         ['end_ap', 'p'],
         ['aa', 'N'],
         ['bb', 'N'],
         ['ee', 'N'],
     ]
     assert macro.form_data == test_form_data, 'Json improperly imported'
Beispiel #7
0
 def test_setdata_file(self):
     macro = searchbot(init=False)
     macro.setData(year=2020, term="Spring", file_name="abcdefghijk.json")
Beispiel #8
0
 def test_setdata_filename(self):
     macro = searchbot(init=False)
     macro.setData(year=2020, term="Wrong Semester")
Beispiel #9
0
 def bot(self):
     return searchbot(year=2020, term="Fall")