示例#1
0
 def tearDown(self):
     cursor = MySQLConnection()
     [offer.delete() for offer in Offer.find()]
     [schedule.delete() for schedule in Schedule.find()]
     cursor.execute('DELETE FROM minitableDayOfTheWeek')
     [timePeriod.delete() for timePeriod in TimePeriod.find()]
     [course.delete() for course in Course.find()]
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()
示例#2
0
class CrawlerForm(forms.Form):
    cycles = Cycle.find()
    timePeriods = TimePeriod.find(year=datetime.datetime.now().year)
    for cycle in cycles:
        cycle.completeMandatoryIdealTerms()
    cycleTuple = ((cycle.idCycle, cycle.name + ' - ' + cycle.dayPeriod + ' - id: ' + str(cycle.idCycle)) for cycle in cycles if len(cycle.mandatoryIdealTerms))
    timePeriodTuple = ((timePeriod.idTimePeriod, str(timePeriod)) for timePeriod in timePeriods)
    cycle = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=cycleTuple, label='Ciclo')
    timePeriod = forms.ChoiceField(choices=timePeriodTuple, label='Período')
示例#3
0
 def tearDown(self):
     cursor = MySQLConnection()
     [offer.delete() for offer in Offer.find()]
     [schedule.delete() for schedule in Schedule.find()]
     cursor.execute('DELETE FROM minitableDayOfTheWeek')
     [timePeriod.delete() for timePeriod in TimePeriod.find()]
     [course.delete() for course in Course.find()]
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()
示例#4
0
 def test_edit_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_edit = self.browser.find_element_by_name('editar')
     button_edit.click()
     self.assertIn('Interface - Offer Edit', self.browser.title)
     dropdown_professor = self.browser.find_element_by_id(
         'id_dropDownProfessor')
     select_professor = Select(dropdown_professor)
     select_professor.select_by_value(str(
         self.second_professor.idProfessor))
     input_classNumber = self.browser.find_element_by_id('id_classNumber')
     input_classNumber.send_keys('1')
     dropdown_practical = self.browser.find_element_by_id(
         'id_dropDownTeoricaPratica')
     select_practical = Select(dropdown_practical)
     select_practical.select_by_value('1')
     input_numberOfRegistrations = self.browser.find_element_by_id(
         'id_numberOfRegistrations')
     input_numberOfRegistrations.send_keys('1')
     self.browser.find_element_by_id("id_listSchedules_1").click()
     self.browser.find_element_by_id("id_listSchedules_2").click()
     button_apply = self.browser.find_element_by_name('Aplicar')
     button_apply.click()
     self.assertIn('Interface - Offer Detail', self.browser.title)
     id_courseCode = self.browser.find_element_by_id('courseCode')
     self.assertEqual(id_courseCode.text, 'tst9999')
     id_name = self.browser.find_element_by_id('name')
     self.assertEqual(id_name.text, 'teste9999')
     id_professor_name = self.browser.find_element_by_id('professor_name')
     self.assertEqual(id_professor_name.text, 'Professor Teste2')
     id_timePeriod = self.browser.find_element_by_id('timePeriod')
     self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
     id_classNumber = self.browser.find_element_by_id('classNumber')
     self.assertEqual(id_classNumber.text, 'T101')
     id_practical = self.browser.find_element_by_id('practical')
     self.assertEqual(id_practical.text, "PRATICA")
     id_numberOfRegistrations = self.browser.find_element_by_id(
         'numberOfRegistrations')
     self.assertEqual(id_numberOfRegistrations.text, '101')
     id_schedules = self.browser.find_element_by_id('schedules')
     self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
     self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
     self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)
示例#5
0
 def updateForm(self):
     timePeriods = TimePeriod.find()
     timePeriods.reverse()
     timePeriodNames = [str(timePeriod) for timePeriod in timePeriods]
     timePeriodIds = [t.idTimePeriod for t in timePeriods]
     timePeriodInfo = zip(timePeriodIds, timePeriodNames)
     courses = Course.find()
     courseCode = [course.courseCode for course in courses]
     courseIds = [course.idCourse for course in courses]
     courseInfo = zip(courseIds, courseCode)
     courseInfo = sorted(courseInfo, key=getKey)
     self.fields['dropDownTimePeriod'] = forms.ChoiceField(widget=forms.Select, choices=timePeriodInfo, label = 'Periodo')
     self.fields['dropDownCourse'] = forms.ChoiceField(widget=forms.Select, choices=courseInfo, label = 'Codigo do Curso')
示例#6
0
 def updateForm(self):
     timePeriods = TimePeriod.find()
     timePeriods.reverse()
     timePeriodNames = [str(timePeriod) for timePeriod in timePeriods]
     timePeriodIds = [t.idTimePeriod for t in timePeriods]
     timePeriodInfo = zip(timePeriodIds, timePeriodNames)
     cycles = Cycle.find()
     cycleName = [cycle.name for cycle in cycles]
     cycleIds = [cycle.idCycle for cycle in cycles]
     cycleInfo = zip(cycleIds, cycleName)
     termInfo = [[0,"Todos"],[1,'1º Semestre'],[2,'2º Semestre'],[3,'3º Semestre'],[4,'4º Semestre'],[5,'5º Semestre'],[6,'6º Semestre'],[7,'7º Semestre'],[8,'8º Semestre'],[9,'9º Semestre'],[10,'10º Semestre']]
     self.fields['dropDownCycle'] = forms.ChoiceField(widget=forms.Select, choices=cycleInfo, label = 'Curso')
     self.fields['dropDownTimePeriod'] = forms.ChoiceField(widget=forms.Select, choices=timePeriodInfo, label = 'Periodo')
     self.fields['dropDownTerm'] = forms.ChoiceField(widget=forms.Select, choices=termInfo, label = 'Semestre')
示例#7
0
 def test_edit_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_edit = self.browser.find_element_by_name('editar')
     button_edit.click()
     self.assertIn('Interface - Offer Edit', self.browser.title)
     dropdown_professor = self.browser.find_element_by_id('id_dropDownProfessor')
     select_professor = Select(dropdown_professor)
     select_professor.select_by_value(str(self.second_professor.idProfessor))
     input_classNumber = self.browser.find_element_by_id('id_classNumber')
     input_classNumber.send_keys('1')
     dropdown_practical = self.browser.find_element_by_id('id_dropDownTeoricaPratica')
     select_practical = Select(dropdown_practical)
     select_practical.select_by_value('1')
     input_numberOfRegistrations = self.browser.find_element_by_id('id_numberOfRegistrations')
     input_numberOfRegistrations.send_keys('1')
     self.browser.find_element_by_id("id_listSchedules_1").click()
     self.browser.find_element_by_id("id_listSchedules_2").click()
     button_apply = self.browser.find_element_by_name('Aplicar')
     button_apply.click()
     self.assertIn('Interface - Offer Detail', self.browser.title)
     id_courseCode = self.browser.find_element_by_id('courseCode')
     self.assertEqual(id_courseCode.text, 'tst9999')
     id_name = self.browser.find_element_by_id('name')
     self.assertEqual(id_name.text, 'teste9999')
     id_professor_name = self.browser.find_element_by_id('professor_name')
     self.assertEqual(id_professor_name.text, 'Professor Teste2')
     id_timePeriod = self.browser.find_element_by_id('timePeriod')
     self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
     id_classNumber = self.browser.find_element_by_id('classNumber')
     self.assertEqual(id_classNumber.text, 'T101')
     id_practical = self.browser.find_element_by_id('practical')
     self.assertEqual(id_practical.text, "PRATICA")
     id_numberOfRegistrations = self.browser.find_element_by_id('numberOfRegistrations')
     self.assertEqual(id_numberOfRegistrations.text, '101')
     id_schedules = self.browser.find_element_by_id('schedules')
     self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
     self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
     self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)
示例#8
0
 def test_delete_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_delete = self.browser.find_element_by_name('deletar')
     button_delete.click()
     alert = self.browser.switch_to.alert
     alert.accept()
     self.assertIn('Interface', self.browser.title)
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertNotIn('Interface - Offer Detail', self.browser.title)
     
示例#9
0
 def test_delete_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_delete = self.browser.find_element_by_name('deletar')
     button_delete.click()
     alert = self.browser.switch_to.alert
     alert.accept()
     self.assertIn('Interface', self.browser.title)
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertNotIn('Interface - Offer Detail', self.browser.title)