예제 #1
0
 def _get_header(self) -> str:
     header = ["RERegister"]
     header.append(f"BAND={self.volume.name}")
     # calculate pre and post issue
     volumes = Volumes()
     vg, nf = volumes.get_neighbours(self.volume.name)
     header.append(f"VG={vg}")
     header.append(f"NF={nf}")
     header.append(f"SUM={len(self.lemmas)}")
     # calculate proof_read status
     fer, kor, unk = self.proof_read
     header.append(f"UNK={unk}")
     header.append(f"KOR={kor}")
     header.append(f"FER={fer}")
     return "{{" + "\n|".join(header) + "\n}}\n"
예제 #2
0
class TestVolumes(TestCase):
    def setUp(self):
        self.re_volumes = Volumes()

    def test_len(self):
        self.assertEqual(84, len(self.re_volumes))

    def test_iter(self):
        iterator = iter(self.re_volumes)
        self.assertEqual("I,1", iterator.__next__())
        for _ in range(0, 47):
            iterator.__next__()
        self.assertEqual("XXIV", iterator.__next__())
        self.assertEqual("I A,1", iterator.__next__())
        for _ in range(0, 17):
            iterator.__next__()
        self.assertEqual("X A", iterator.__next__())
        self.assertEqual("S I", iterator.__next__())
        for _ in range(0, 13):
            iterator.__next__()
        self.assertEqual("S XV", iterator.__next__())
        self.assertEqual("R", iterator.__next__())

    def test_iter_first_series(self):
        counter = 0
        for volume in self.re_volumes.first_series:
            compare(VolumeType.FIRST_SERIES, volume.type)
            counter += 1
        compare(49, counter)

    def test_iter_second_series(self):
        counter = 0
        for volume in self.re_volumes.second_series:
            compare(VolumeType.SECOND_SERIES, volume.type)
            counter += 1
        compare(19, counter)

    def test_iter_supplements(self):
        counter = 0
        for volume in self.re_volumes.supplements:
            compare(VolumeType.SUPPLEMENTS, volume.type)
            counter += 1
        compare(15, counter)

    def test_iter_register(self):
        counter = 0
        for volume in self.re_volumes.register:
            compare(VolumeType.REGISTER, volume.type)
            counter += 1
        compare(1, counter)

    def test_iter_all_volumes(self):
        counter = 0
        current_type = VolumeType.FIRST_SERIES
        following_types = [VolumeType.SECOND_SERIES,
                           VolumeType.SUPPLEMENTS,
                           VolumeType.REGISTER]
        for volume in self.re_volumes.all_volumes:
            compare(Volume, type(volume))
            if volume.type == current_type:
                pass
            elif volume.type == following_types[0]:
                current_type = following_types[0]
                del following_types[0]
            else:  # pragma: no cover
                raise TypeError("The types hasn't the right order. This section should never reached")
            counter += 1
        compare(84, counter)

    def test_iter_main_volumes(self):
        counter = 0
        for _ in self.re_volumes.main_volumes:
            counter += 1
        compare(50, counter)

    def test_get(self):
        with self.assertRaises(ReDatenException):
            print(self.re_volumes["tada"])
        with self.assertRaises(ReDatenException):
            print(self.re_volumes[1])
        compare("I,1", self.re_volumes["I,1"].name)

    def test_pre_post(self):
        compare(("", "I,2"), self.re_volumes.get_neighbours("I,1"))
        compare(("I,2", "II,2"), self.re_volumes.get_neighbours("II,1"))
        compare(("XXIV", "I A,2"), self.re_volumes.get_neighbours("I A,1"))
        compare(("S XV", ""), self.re_volumes.get_neighbours("R"))

    def test__volume_part_of_main_volume(self):
        compare(True, Volumes.is_volume_part_of_main_volume("I,1", "I"))
        compare(False, Volumes.is_volume_part_of_main_volume("II,1", "I"))
        compare(False, Volumes.is_volume_part_of_main_volume("I,1", "II"))
        compare(False, Volumes.is_volume_part_of_main_volume("I,1", "XI"))
        compare(True, Volumes.is_volume_part_of_main_volume("II,1", "II"))