Exemple #1
0
    def test_absolutize(self):
        "Absolutize relative to an absolute header."

        base = Header(1, 234, 567, 8, 9)
        ah1 = absolutize(base, base)
        self.assertAttrs(ah1, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=True, abs_time=234, real_time=234,
                         real_size=567, real_type=8, real_ms_id=9)

        h2 = Header(1, 234, 567, 8, None)
        ah2 = absolutize(h2, base)
        self.assertAttrs(ah2, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=468, real_time=234,
                         real_size=567, real_type=8, real_ms_id=None)


        h3 = Header(1, 234, None, None, None)
        ah3 = absolutize(h3, base)
        self.assertAttrs(ah3, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=468, real_time=234,
                         real_size=None, real_type=None, real_ms_id=None)

        h4 = Header(1, None, None, None, None)
        ah4 = absolutize(h4, base)
        self.assertAttrs(ah4, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=468, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)
Exemple #2
0
    def test_absolutize_with_zero(self):
        "Absolutize relative to an absolute header, using 0 values."

        base = Header(1, 234, 567, 8, 9)
        self.assertAttrs(base, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=True, abs_time=234, real_time=234,
                         real_size=567, real_type=8, real_ms_id=9)

        h1 = Header(0, 0, 0, 0, 0)
        ah1 = absolutize(h1, base)
        self.assertAttrs(ah1, cs_id=0, time=0, size=0, type=0, ms_id=0,
                         absolute=True, abs_time=0, real_time=0,
                         real_size=0, real_type=0, real_ms_id=0)

        h2 = Header(0, 0, 0, 0, None)
        ah2 = absolutize(h2, base)
        self.assertAttrs(ah2, cs_id=0, time=0, size=0, type=0, ms_id=9,
                         absolute=False, abs_time=234, real_time=0,
                         real_size=0, real_type=0, real_ms_id=None)


        h3 = Header(0, 0, None, None, None)
        ah3 = absolutize(h3, base)
        self.assertAttrs(ah3, cs_id=0, time=0, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=234, real_time=0,
                         real_size=None, real_type=None, real_ms_id=None)

        h4 = Header(0, None, None, None, None)
        ah4 = absolutize(h4, base)
        self.assertAttrs(ah4, cs_id=0, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=468, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)
Exemple #3
0
    def test_absolutize_relative(self):
        "Absolutize relative to a relative (absolutized) header."

        base = Header(1, 234, 567, 8, 9)
        rel1 = Header(1, 10, 567, 8, None)
        absd1 = absolutize(rel1, base)
        self.assertAttrs(absd1, cs_id=1, time=10, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=244, real_time=10,
                         real_size=567, real_type=8, real_ms_id=None)

        h1 = Header(1, 20, 567, 8, None)
        a1h1 = absolutize(h1, absd1)
        self.assertAttrs(a1h1, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=264, real_time=20,
                         real_size=567, real_type=8, real_ms_id=None)

        h2 = Header(1, 20, None, None, None)
        a1h2 = absolutize(h2, absd1)
        self.assertAttrs(a1h2, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=264, real_time=20,
                         real_size=None, real_type=None, real_ms_id=None)

        h3 = Header(1, None, None, None, None)
        a1h3 = absolutize(h3, absd1)
        self.assertAttrs(a1h3, cs_id=1, time=10, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=254, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)

        rel2 = Header(1, 10, None, None, None)
        absd2 = absolutize(rel2, base)
        self.assertAttrs(absd2, cs_id=1, time=10, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=244, real_time=10,
                         real_size=None, real_type=None, real_ms_id=None)

        a2h1 = absolutize(h1, absd2)
        self.assertAttrs(a2h1, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=264, real_time=20,
                         real_size=567, real_type=8, real_ms_id=None)

        a2h2 = absolutize(h2, absd2)
        self.assertAttrs(a2h2, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=264, real_time=20,
                         real_size=None, real_type=None, real_ms_id=None)

        a2h3 = absolutize(h3, absd2)
        self.assertAttrs(a2h3, cs_id=1, time=10, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=254, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)

        rel3 = Header(1, None, None, None, None)
        absd3 = absolutize(rel3, base)
        self.assertAttrs(absd3, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=468, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)

        a3h1 = absolutize(h1, absd3)
        self.assertAttrs(a3h1, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=488, real_time=20,
                         real_size=567, real_type=8, real_ms_id=None)

        a3h2 = absolutize(h2, absd3)
        self.assertAttrs(a3h2, cs_id=1, time=20, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=488, real_time=20,
                         real_size=None, real_type=None, real_ms_id=None)

        a3h3 = absolutize(h3, absd3)
        self.assertAttrs(a3h3, cs_id=1, time=234, size=567, type=8, ms_id=9,
                         absolute=False, abs_time=702, real_time=None,
                         real_size=None, real_type=None, real_ms_id=None)