Exemple #1
0
    def test_knows_when_year_is_not_completed(self):
        year = Year(year=9)
        year.extend_subjects(
            subjects=[MagicMock(
                passed=True), MagicMock(passed=None)])

        self.assertEqual(year.completed, False)
    def setUp(self):
        python = Subject.half_year(name='Intro to Python')
        history = Subject.advanced_placement(name='AP Modern World History')
        english = Subject.honors(name='H English')
        science = Subject.college_prep(name='CP Biology')
        math = Subject.honors(name='H Geometry')
        spanish = Subject.language(name='Spanish 3')

        python.sem1.mp1.grade = 98.07
        python.sem1.mp2.grade = 99.42
        history.sem1.mp1.grade = 93.71
        history.sem1.mp2.grade = 89.29
        history.sem1.exam = 76
        english.sem1.mp1.grade = 92.30
        english.sem1.mp2.grade = 96.85
        science.sem1.mp1.grade = 95.04
        science.sem1.mp2.grade = 94.95
        math.sem1.mp1.grade = 97.34
        math.sem1.mp2.grade = 99.49
        spanish.sem1.mp1.grade = 91.72
        spanish.sem1.mp2.grade = 91.80

        self.subjects = [python, history, english, science, math, spanish]

        self.year = Year(year=9)
        self.year.extend_subjects(subjects=self.subjects)
Exemple #3
0
    def test_can_extend_the_list_of_subjects(self):
        subject = Subject('English')

        year = Year(year=10)
        year.extend_subjects(subjects=[subject])

        self.assertEqual(year.subjects, [subject])
 def __init__(self, name: str):
     self.name = name
     self._year = 0  # Grade
     self._mp = 0  # current
     self.high_school = {
         9: Year(9),
         10: Year(10),
         11: Year(11),
         12: Year(12),
     }
    def setUp(self):
        python = MagicMock(credit=0.500,
                           final=Grade(grade=98.07, weight=0.500),
                           passed=True)
        python.name = 'python'
        history = MagicMock(name='history',
                            credit=1.000,
                            final=Grade(grade=92.71, weight=1.100),
                            passed=True)
        history.name = 'history'
        science = MagicMock(name='science',
                            credit=1.000,
                            final=Grade(grade=55.89, weight=1.000),
                            passed=False)
        science.name = 'science'
        gym = MagicMock(name='gym',
                        credit=0.500,
                        final=Grade(grade=99.02, weight=0.500),
                        passed=True)
        gym.name = 'gym'
        english = MagicMock(name='english',
                            credit=1.000,
                            final=Grade(grade=94.30, weight=1.050),
                            passed=True)
        english.name = 'english'
        math = MagicMock(name='math',
                         credit=1.000,
                         final=Grade(grade=98.63, weight=1.050),
                         passed=True)
        math.name = 'math'

        self.subjects9 = [python, history, science]

        self.subjects10 = [gym, english, math]

        self.year9 = Year(year=9)
        self.year9.extend_subjects(subjects=self.subjects9)
        self.year10 = Year(year=10)
        self.year10.extend_subjects(subjects=self.subjects10)

        self.years = [self.year9, self.year10]
Exemple #6
0
    def test_figures_out_credits_earned_out_of_total_credits(self):
        year = Year(year=9)
        year.extend_subjects(subjects=self.subjects)
        year.extend_subjects(subjects=[
            MagicMock(credit=1, final=Grade(grade=49.26), passed=False)
        ])

        self.assertEqual(year.credits, 4)
        self.assertEqual(year.credits_earned, 3)
class ReportCardTest(unittest.TestCase):
    def setUp(self):
        python = Subject.half_year(name='Intro to Python')
        history = Subject.advanced_placement(name='AP Modern World History')
        english = Subject.honors(name='H English')
        science = Subject.college_prep(name='CP Biology')
        math = Subject.honors(name='H Geometry')
        spanish = Subject.language(name='Spanish 3')

        python.sem1.mp1.grade = 98.07
        python.sem1.mp2.grade = 99.42
        history.sem1.mp1.grade = 93.71
        history.sem1.mp2.grade = 89.29
        history.sem1.exam = 76
        english.sem1.mp1.grade = 92.30
        english.sem1.mp2.grade = 96.85
        science.sem1.mp1.grade = 95.04
        science.sem1.mp2.grade = 94.95
        math.sem1.mp1.grade = 97.34
        math.sem1.mp2.grade = 99.49
        spanish.sem1.mp1.grade = 91.72
        spanish.sem1.mp2.grade = 91.80

        self.subjects = [python, history, english, science, math, spanish]

        self.year = Year(year=9)
        self.year.extend_subjects(subjects=self.subjects)

    def test_takes_mp_grade_year(self):
        report_card = ReportCard(mp=2, year=self.year)

        self.assertEqual(report_card._mp, 2)
        self.assertIsInstance(report_card._year, Year)

    def test_creates_lists_of_subjects_and_has_total_credits(self):
        report_card = ReportCard(mp=2, year=self.year)

        self.assertEqual(report_card._subjects, self.subjects)
        self.assertEqual(report_card._subjects_in_mp, self.subjects)
        self.assertEqual(report_card._grades,
                         [subject.mp[2].grade for subject in self.subjects])
        self.assertEqual(report_card._credits, 5.5)

    def test_calculates_unweighted_and_weighted_nga(self):
        report_card = ReportCard(mp=2, year=self.year)

        self.assertEqual(report_card.unweighted_nga, 95.167)
        self.assertEqual(report_card.weighted_nga, 98.218)

    def test_calculates_unweighted_and_weighted_gpa(self):
        report_card = ReportCard(mp=2, year=self.year)

        self.assertEqual(report_card.unweighted_gpa, 3.778)
        self.assertEqual(report_card.weighted_gpa, 4.112)

    def test_figures_out_honor_roll(self):
        report_card = ReportCard(mp=2, year=self.year)

        self.assertEqual(report_card.honor_roll, 'First Honor Roll')

    def test_writes_report_card(self):
        report_card = ReportCard(mp=2, year=self.year)

        report_card._test_write()
class TranscriptTest(unittest.TestCase):
    def setUp(self):
        python = MagicMock(credit=0.500,
                           final=Grade(grade=98.07, weight=0.500),
                           passed=True)
        python.name = 'python'
        history = MagicMock(name='history',
                            credit=1.000,
                            final=Grade(grade=92.71, weight=1.100),
                            passed=True)
        history.name = 'history'
        science = MagicMock(name='science',
                            credit=1.000,
                            final=Grade(grade=55.89, weight=1.000),
                            passed=False)
        science.name = 'science'
        gym = MagicMock(name='gym',
                        credit=0.500,
                        final=Grade(grade=99.02, weight=0.500),
                        passed=True)
        gym.name = 'gym'
        english = MagicMock(name='english',
                            credit=1.000,
                            final=Grade(grade=94.30, weight=1.050),
                            passed=True)
        english.name = 'english'
        math = MagicMock(name='math',
                         credit=1.000,
                         final=Grade(grade=98.63, weight=1.050),
                         passed=True)
        math.name = 'math'

        self.subjects9 = [python, history, science]

        self.subjects10 = [gym, english, math]

        self.year9 = Year(year=9)
        self.year9.extend_subjects(subjects=self.subjects9)
        self.year10 = Year(year=10)
        self.year10.extend_subjects(subjects=self.subjects10)

        self.years = [self.year9, self.year10]

    def test_takes_years_and_creates_attributes(self):
        transcript = Transcript(years=self.years)

        self.assertEqual(transcript._years, self.years)
        self.assertEqual(transcript._subjects,
                         self.subjects9 + self.subjects10)

    def test_figures_out_credtis_earned_out_of_total_credits(self):
        transcript = Transcript(years=self.years)

        self.assertEqual(transcript.credits, 5)
        self.assertEqual(transcript.credits_earned, 4)

    def test_calculates_unweighted_and_weighted_nga(self):
        transcript = Transcript(years=self.years)

        self.assertEqual(transcript.unweighted_nga, 89.833)
        self.assertEqual(transcript.weighted_nga, 91.89)

    def test_calculates_unweighted_and_weighted_gpa(self):
        transcript = Transcript(years=self.years)

        self.assertEqual(transcript.unweighted_gpa, 3.223)
        self.assertEqual(transcript.weighted_gpa, 3.557)

    def test_writes_transcript(self):
        transcript = Transcript(years=self.years)

        transcript._test_write()
Exemple #9
0
    def test_has_unweighted_and_weighted_gpa(self):
        year = Year(year=9)
        year.extend_subjects(subjects=self.subjects)

        self.assertEqual(year.unweighted_gpa, 3.780)
        self.assertEqual(year.weighted_gpa, 4.280)
Exemple #10
0
    def test_calculates_unweighted_and_weighted_nga(self):
        year = Year(year=9)
        year.extend_subjects(subjects=self.subjects)

        self.assertEqual(year.unweighted_nga, 94.667)
        self.assertEqual(year.weighted_nga, 99.450)
Exemple #11
0
    def test_remove_subject_raises_lookup_error_if_name_that_does_not_exist_in_subjects_list(
            self):
        year = Year(year=11)

        with self.assertRaises(LookupError):
            year.remove_subject('Math')
Exemple #12
0
    def test_can_remove_a_subject_from_the_list_of_subjects(self):
        year = Year(year=11)
        year.extend_subjects(subjects=[Subject('Math')])
        year.remove_subject(remove='Math')

        self.assertEqual(year.subjects, [])
Exemple #13
0
    def test_has_year_and_subjects_list(self):
        year = Year(year=9)

        self.assertEqual(year.year, 9)
        self.assertEqual(year.subjects, [])