def test_insert_all_with_overwrite(self):

        # AB1 CD EF + AB2 = AB2 CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ab1 = TimeNode(self.a, self.b, "ab")
        chain.insert_all([ab, cd, ef, ab1])
        head = chain.get_head()
        self.check_ordering(head, ab1, cd, ef)

        # CD EF AB1 + AB2 = AB2 CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ab1 = TimeNode(self.a, self.b, "ab")
        chain.insert_all([cd, ef, ab, ab1])
        head = chain.get_head()
        self.check_ordering(head, ab1, cd, ef)

        # AB CD EF + AD = AD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ad = TimeNode(self.a, self.d, "ad")
        chain.insert_all([ab, cd, ef, ad])
        head = chain.get_head()
        self.check_ordering(head, ad, ef, None)

        # AB CD EF + AD + DE = AD DE EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ad = TimeNode(self.a, self.d, "ad")
        de = TimeNode(self.d, self.e, "de")
        chain.insert_all([ab, cd, ef, ad, de])
        head = chain.get_head()
        self.check_ordering(head, ad, de, ef)

        # AC DE EF + BD = BD DE EF
        chain = TimeNodeChain()
        ac = TimeNode(self.a, self.c, "ac")
        de = TimeNode(self.d, self.e, "de")
        ef = TimeNode(self.e, self.f, "ef")
        bd = TimeNode(self.b, self.d, "bd")
        chain.insert_all([ac, de, ef, bd])
        head = chain.get_head()
        self.check_ordering(head, bd, de, ef)

        # AC DE EF + BD + BE = BE EF
        chain = TimeNodeChain()
        ac = TimeNode(self.a, self.c, "ac")
        de = TimeNode(self.d, self.e, "de")
        ef = TimeNode(self.e, self.f, "ef")
        bd = TimeNode(self.b, self.d, "bd")
        be = TimeNode(self.b, self.e, "be")
        chain.insert_all([ac, de, ef, bd, be])
        head = chain.get_head()
        self.check_ordering(head, be, ef, None)

        # BE EF FG + EG = BE EG
        chain = TimeNodeChain()
        be = TimeNode(self.b, self.e, "be")
        ef = TimeNode(self.e, self.f, "ef")
        fg = TimeNode(self.f, self.g, "fg")
        eg = TimeNode(self.e, self.g, "eg")
        chain.insert_all([be, ef, fg, eg])
        head = chain.get_head()
        self.check_ordering(head, be, eg, None)

        # AB CD EF + GH + AG = AG GH
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        gh = TimeNode(self.g, self.h, "gh")
        ag = TimeNode(self.a, self.g, "ag")
        chain.insert_all([ab, cd, ef, gh, ag])
        head = chain.get_head()
        self.check_ordering(head, ag, gh, None)
Beispiel #2
0
    def test_insert_all_with_overwrite(self):

        # AB1 CD EF + AB2 = AB2 CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ab1 = TimeNode(self.a, self.b, "ab")
        chain.insert_all([ab, cd, ef, ab1])
        head = chain.get_head()
        self.check_ordering(head, ab1, cd, ef)

        # CD EF AB1 + AB2 = AB2 CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ab1 = TimeNode(self.a, self.b, "ab")
        chain.insert_all([cd, ef, ab, ab1])
        head = chain.get_head()
        self.check_ordering(head, ab1, cd, ef)

        # AB CD EF + AD = AD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ad = TimeNode(self.a, self.d, "ad")
        chain.insert_all([ab, cd, ef, ad])
        head = chain.get_head()
        self.check_ordering(head, ad, ef, None)

        # AB CD EF + AD + DE = AD DE EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        ad = TimeNode(self.a, self.d, "ad")
        de = TimeNode(self.d, self.e, "de")
        chain.insert_all([ab, cd, ef, ad, de])
        head = chain.get_head()
        self.check_ordering(head, ad, de, ef)

        # AC DE EF + BD = BD DE EF
        chain = TimeNodeChain()
        ac = TimeNode(self.a, self.c, "ac")
        de = TimeNode(self.d, self.e, "de")
        ef = TimeNode(self.e, self.f, "ef")
        bd = TimeNode(self.b, self.d, "bd")
        chain.insert_all([ac, de, ef, bd])
        head = chain.get_head()
        self.check_ordering(head, bd, de, ef)

        # AC DE EF + BD + BE = BE EF
        chain = TimeNodeChain()
        ac = TimeNode(self.a, self.c, "ac")
        de = TimeNode(self.d, self.e, "de")
        ef = TimeNode(self.e, self.f, "ef")
        bd = TimeNode(self.b, self.d, "bd")
        be = TimeNode(self.b, self.e, "be")
        chain.insert_all([ac, de, ef, bd, be])
        head = chain.get_head()
        self.check_ordering(head, be, ef, None)

        # BE EF FG + EG = BE EG
        chain = TimeNodeChain()
        be = TimeNode(self.b, self.e, "be")
        ef = TimeNode(self.e, self.f, "ef")
        fg = TimeNode(self.f, self.g, "fg")
        eg = TimeNode(self.e, self.g, "eg")
        chain.insert_all([be, ef, fg, eg])
        head = chain.get_head()
        self.check_ordering(head, be, eg, None)

        # AB CD EF + GH + AG = AG GH
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        gh = TimeNode(self.g, self.h, "gh")
        ag = TimeNode(self.a, self.g, "ag")
        chain.insert_all([ab, cd, ef, gh, ag])
        head = chain.get_head()
        self.check_ordering(head, ag, gh, None)
    def test_insert_all(self):

        # Test proper initialization
        ab = TimeNode(self.a, self.b, "ab")
        self.assertEquals("ab", ab.id)
        self.assertEquals(self.a, ab.start)
        self.assertEquals(self.b, ab.end)
        self.assertIsNone(ab.next)
        chain1 = TimeNodeChain()
        self.assertIsNone(chain1.get_head())
        chain2 = TimeNodeChain()
        self.assertEquals(ab, chain2.insert(ab))
        self.assertEquals(ab, chain2.get_head())

        # AB CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ab, cd, ef])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # EF CD AB (inserted backwards)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ef, cd, ab])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # CD EF AB (mixed ordering)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([cd, ef, ab])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # AB EF CD (more mixed orderings)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ab, ef, cd])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # AB BC CD (exactly equal start/end times, out of order)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        bc = TimeNode(self.c, self.d, "bc")
        cd = TimeNode(self.e, self.f, "cd")
        chain.insert_all([ab, bc, cd])
        head = chain.get_head()
        self.check_ordering(head, ab, bc, cd)

        # AB CD BC (exactly equal start/end times, out of order)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        bc = TimeNode(self.c, self.d, "bc")
        cd = TimeNode(self.e, self.f, "cd")
        chain.insert_all([ab, cd, bc])
        head = chain.get_head()
        self.check_ordering(head, ab, bc, cd)
Beispiel #4
0
    def test_insert_all(self):

        # Test proper initialization
        ab = TimeNode(self.a, self.b, "ab")
        self.assertEquals("ab", ab.id)
        self.assertEquals(self.a, ab.start)
        self.assertEquals(self.b, ab.end)
        self.assertIsNone(ab.next)
        chain1 = TimeNodeChain()
        self.assertIsNone(chain1.get_head())
        chain2 = TimeNodeChain()
        self.assertEquals(ab, chain2.insert(ab))
        self.assertEquals(ab, chain2.get_head())

        # AB CD EF
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ab, cd, ef])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # EF CD AB (inserted backwards)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ef, cd, ab])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # CD EF AB (mixed ordering)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([cd, ef, ab])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # AB EF CD (more mixed orderings)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        cd = TimeNode(self.c, self.d, "cd")
        ef = TimeNode(self.e, self.f, "ef")
        chain.insert_all([ab, ef, cd])
        head = chain.get_head()
        self.check_ordering(head, ab, cd, ef)

        # AB BC CD (exactly equal start/end times, out of order)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        bc = TimeNode(self.c, self.d, "bc")
        cd = TimeNode(self.e, self.f, "cd")
        chain.insert_all([ab, bc, cd])
        head = chain.get_head()
        self.check_ordering(head, ab, bc, cd)

        # AB CD BC (exactly equal start/end times, out of order)
        chain = TimeNodeChain()
        ab = TimeNode(self.a, self.b, "ab")
        bc = TimeNode(self.c, self.d, "bc")
        cd = TimeNode(self.e, self.f, "cd")
        chain.insert_all([ab, cd, bc])
        head = chain.get_head()
        self.check_ordering(head, ab, bc, cd)