Ejemplo n.º 1
0
 def testRemoveDiscipline(self):
     discipline = Discipline(10, 'Economics')
     self._discipline.removeDiscipline(discipline)
     self.assertEqual(len(self._discipline._disciplines), 9)
     discipline = Discipline(34, 'Math')
     self.assertRaises(IdException, self._discipline.removeDiscipline,
                       discipline)
Ejemplo n.º 2
0
 def __add_data(self):
     student1 = Student("123", "Rusu Raul")
     student2 = Student("456", "Petrica George")
     student3 = Student("1231", "Trif George")
     student4 = Student("1842", "Trif Maria")
     student5 = Student("1255", "Pastarnac Giorgiana")
     student6 = Student("9523", "Almasan Catalin")
     student7 = Student("8234", "Indian Razvan")
     student8 = Student("752234", "Paul Andrei")
     student9 = Student("92424", "Marian Alex")
     discipline1 = Discipline("111", "Math")
     discipline2 = Discipline("222", "FP")
     discipline3 = Discipline("333", "Algebra")
     discipline4 = Discipline("444", "ASC")
     self.__studentRepository.add(student1)
     self.__studentRepository.add(student2)
     self.__studentRepository.add(student3)
     self.__studentRepository.add(student4)
     self.__studentRepository.add(student5)
     self.__studentRepository.add(student6)
     self.__studentRepository.add(student7)
     self.__studentRepository.add(student8)
     self.__studentRepository.add(student9)
     self.__disciplineRepository.add(discipline1)
     self.__disciplineRepository.add(discipline2)
     self.__disciplineRepository.add(discipline4)
     self.__disciplineRepository.add(discipline3)
     grade1 = Grade("111", "123", 9)
     grade2 = Grade("444", "1231", 7)
     grade3 = Grade("333", "9523", 4)
     self.__gradeRepository.add(grade1)
     self.__gradeRepository.add(grade2)
     self.__gradeRepository.add(grade3)
Ejemplo n.º 3
0
 def testAddDiscipline(self):
     discipline = Discipline(34, 'Math')
     self._discipline.addDiscipline(discipline)
     self.assertEqual(len(self._discipline._disciplines), 11)
     discipline = Discipline(34, 'Math')
     self.assertRaises(IdException, self._discipline.addDiscipline,
                       discipline)
Ejemplo n.º 4
0
 def UpdateD(self, disciplineID, name):
     """
     update a discipline in disciplineRepository
     :param disciplineID:
     :param name:
     """
     discipline = Discipline(disciplineID, "")
     newDiscipline = Discipline(disciplineID, name)
     self.__disciplineRepository.Update(discipline, newDiscipline)
Ejemplo n.º 5
0
 def RemoveD(self, disciplineID):
     """
     remove a discipline from studentRepository
     :param disciplineID:
     """
     disciplineToRemove = Discipline(disciplineID, "")
     self.__disciplineRepository.Remove(disciplineToRemove)
     self.__gradeRepository.remove_all_discipline(disciplineID)
Ejemplo n.º 6
0
 def AddDisciplineToRepo(self, disciplineID, disciplineName):
     """
     Add a discipline to disciplineRepository
     :param disciplineID:
     :param disciplineName:
     :return:
     """
     discipline = Discipline(disciplineID, disciplineName)
     self.__disciplineRepository.add(discipline)
Ejemplo n.º 7
0
def rndD():
    ran = [[1, 'Algebra'], [2, 'Geometry'], [3, 'Physics'], [4, 'Chemistry'],
           [5, 'Biology'], [6, 'Spanish'], [7, 'French'], [8, 'Calculus'],
           [9, 'World History'], [10, 'Economics']]
    res = []
    for i in range(10):
        discipline = Discipline(ran[i][0], ran[i][1])
        res.append(discipline)
    return res
Ejemplo n.º 8
0
 def testUpdateDiscipline(self):
     discipline = Discipline(34, 'Math')
     self._discipline.addDiscipline(discipline)
     self._discipline.updateDiscipline(34, 'English')
     self.assertEqual(discipline.Name, 'English')
     self.assertRaises(IdException, self._discipline.updateDiscipline, 20,
                       'Math')
     self.assertRaises(NameException, self._discipline.updateDiscipline, 34,
                       'English')
Ejemplo n.º 9
0
 def testAddGradeValidation(self):
     student = Student(70, 'Alex')
     self._student.addStudent(student)
     discipline = Discipline(34, 'Math')
     self._discipline.addDiscipline(discipline)
     grade = Grade(discipline, student, 8)
     self.assertRaises(GradeException, self._grade.addGradeValidation,
                       grade)
     discipline = Discipline(2, 'Geometry')
     grade = Grade(discipline, student, 8)
     self.assertRaises(GradeException, self._grade.addGradeValidation,
                       grade)
     student = Student(1, 'Javier Moro')
     discipline = Discipline(34, 'Math')
     grade = Grade(discipline, student, 8)
     self.assertRaises(GradeException, self._grade.addGradeValidation,
                       grade)
     student = Student(1, 'Javier Moro')
     discipline = Discipline(10, 'Economics')
     grade = Grade(discipline, student, 8)
     self._grade.addGradeValidation(grade)
     self.assertEqual(len(self._grade._grades), 11)
Ejemplo n.º 10
0
 def GradeStudentAtD(self, studentID, disciplineID, gradeValue):
     """
     add a new grade to gradeRepository
     :param studentID:
     :param disciplineID:
     :param gradeValue:
     """
     gradeValue = int(gradeValue)
     if (gradeValue <= 0 or gradeValue >= 10):
         raise ValueError("grade should be a number between 0 and 10")
     self.__disciplineRepository.FindElement(Discipline(disciplineID, ""))
     self.__studentRepository.FindElement(Student(studentID, "5"))
     grade = Grade(disciplineID, studentID, gradeValue)
     self.__gradeRepository.add(grade)
Ejemplo n.º 11
0
def rndD():
    ran = [[1, 'Algebra'], [2, 'Geometry'], [3, 'Physics'], [4, 'Chemistry'],
           [5, 'Biology'], [6, 'Spanish'], [7, 'French'], [8, 'Calculus'],
           [9, 'World History'], [10, 'Economics'], [11, 'Physical Education'],
           [12, 'Digital Arts'], [13, 'Web Design'], [14, 'English'],
           [15, 'Geography'], [16, 'Latin'], [17, 'Grammar'],
           [18, 'Journalism'], [19, 'Painting'], [20, 'Astronomy'],
           [21, 'Fundamentals of Programming'], [22, 'CSA'],
           [23, 'Object-oriented Programming'], [24, 'Computational Logic']]
    l = []
    res = []
    for i in range(10):
        elem = random.choice(ran)
        l.append(elem)
        ran.remove(elem)
    for i in range(10):
        discipline = Discipline(l[i][0], l[i][1])
        res.append(discipline)
    '''f = open('disciplines.pickle', "wb")
    pickle.dump(res, f)
    f.close()'''
    return res
Ejemplo n.º 12
0
 def testGrade(self):
     student = Student(11, 'name')
     discipline = Discipline(11, 'name')
     self.assertRaises(GradeException, Grade, discipline, student, 11)
     grade = Grade(discipline, student, 10)
     self.assertEqual(grade.GradeV, 10)
Ejemplo n.º 13
0
 def testDiscipline(self):
     self.assertRaises(IdException, Discipline, None, 'name')
     self.assertRaises(IdException, Discipline, -2, 'name')
     self.assertRaises(NameException, Discipline, 11, '')
     discipline = Discipline(11, 'name')
Ejemplo n.º 14
0
    def fetch_info(self, fetch_files=False):
        page = requests.get(self.url)
        soup = BeautifulSoup(page.content, 'html.parser')
        self.disciplines = []

        if self.name == 'gpjpn2017':
            day = 12
            month = 11
            year = 2017
        elif self.name == 'gpf1718':
            day = 10
            month = 12
            year = 2017
        else:
            date_matches = self.date_re.findall(soup.get_text())
            day = int(date_matches[1][0])
            month = int(date_matches[1][1])
            year = int(date_matches[1][2])
        if month not in (10, 11, 12, 1, 2, 3, 4):
            month_save = month
            month = day
            day = month_save
        self.date = date(year, month, day)

        links = soup.find_all('a')
        num_links = len(links)
        cur_link = 0
        for discipline_type in list(DisciplineType):
            discipline = Discipline(self.season, self, discipline_type)
            while cur_link < num_links:
                link = links[cur_link]
                if not link.text:
                    cur_link += 1
                    continue
                href = link['href']
                if 'Entries' in link.text and discipline.entries_url is not None:
                    break
                elif 'Entries' in link.text:
                    discipline.entries_url = self.url + href
                elif 'Result' in link.text:
                    discipline.results_url = self.url + href
                elif 'Panel' in link.text or 'Officials' in link.text:
                    discipline.panel_urls.append(self.url + href)
                elif 'Scores' in link.text or 'Judges Score' in link.text:
                    discipline.score_urls.append(self.url + href)

                    # Skip over preliminary/qualifying/junior rounds.
                    if 'Preliminary' in href or 'Junior' in href:  # wc2011, gpf0910
                        discipline = Discipline(self.season, self,
                                                discipline_type)
                    elif 'QB' in href or 'QA' in href:  # wc2005
                        discipline.panel_urls = []
                        discipline.score_urls = []
                cur_link += 1
            discipline.create_segments()
            if fetch_files:
                discipline.get_page()
            for segment in discipline.segments:
                segment.panel.parse_html()
                segment.num_judges = segment.panel.num_judges

                # fc2005 pairs short is missing the panel page.
                if (segment.event.name == 'fc2006'
                        and segment.discipline == DisciplineType.pairs
                        and segment.type == SegmentType.short):
                    segment.num_judges = 12

            self.disciplines.append(discipline)
        if fetch_files:
            self.pdfs_to_csvs()