Exemplo n.º 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()
Exemplo n.º 2
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()
Exemplo n.º 3
0
def checkforschedule(day, start, end):
    """Returns a schedule object created after a bank query using the
    parameters or a new schedule, if a schedule is not found"""
    schedule = Schedule.find(dayOfTheWeek_equal=day,
                             start_equal=start,
                             end_equal=end)
    if schedule:
        schedule = schedule[0]
    else:
        schedule = Schedule(day, end, 'semanal', start)
    return schedule
Exemplo n.º 4
0
 def updateForm(self):
     professors = Professor.find()
     professorName = [professor.name for professor in professors]
     professorIds = [professor.idProfessor for professor in professors]
     professorInfo = zip(professorIds, professorName)
     professorInfo = sorted(professorInfo, key=getKey)
     schedules = Schedule.find()
     scheduleName = schedules
     scheduleIds = [schedule.idSchedule for schedule in schedules]
     scheduleInfo = zip(scheduleIds, scheduleName)
     self.fields['dropDownProfessor'] = forms.ChoiceField(widget=forms.Select, choices=professorInfo, label = "Professor")
     self.fields['listSchedules'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=scheduleInfo, label = 'Horários')
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)