Hong-Phuc Bui
2024-07-01 82915d6ee31fd763e7cd2391a25c225060cf1120
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest
from mystudy.lecture import Lecture, parse_lecture_line
 
EPSILON = 0.01
 
class LectureTestCase(unittest.TestCase):
    def test_constructor(self):
        n = "Mathematik"
        ects = 5
        f = 2.5
        mathe2 = Lecture(n, ects, f)
        english = Lecture("English", 2, 1)
        print(mathe2)
        print(english)
        text = f"{mathe2} am Montag"
        text2 = f"{mathe2} im Studiengang MAM"
        print(text)
 
 
    def test_cal_effort(self):
        n = "Mathematik",
        ects = 5
        f = 2.5
        mathe2 = Lecture(n, ects, f)
        e1 = mathe2.cal_effort()
        # self.assertEqual(e1, 6)
        diff = abs(e1 - 6.25)
        self.assertTrue(diff < EPSILON)
 
        e2 = mathe2.cal_effort(time_per_ects=20)
        diff = abs(e2 - 2.92)
        # self.assertEqual(e2, 7)
        self.assertTrue(diff < EPSILON)
 
    def test_parse_lecture_line(self):
        data = "English; 3 ; 2"
        english = parse_lecture_line(data)
        text = "Vorlesungsname English ECTS: 2"
        self.assertEqual(text, f"{english}")
 
 
if __name__ == '__main__':
    unittest.main()