Esempio n. 1
0
    def test_full_align(self):

        ra = RecordAligner()
        records = [Record(t1), Record(t2), Record(t3)]
        seed, mappings = ra.align(records)

        self.assertEqual(3, len(mappings))

        # all the elements from seed should matched to other 2 trees
        for tag in ['root', 'a', 'b', 'c']:
            e = seed[0].xpath('//%s' % tag)[0]
            expected = []
            for record, mapping in mappings.items():
                expected.append(mapping[e].tag)
            self.assertEqual([tag] * 3, expected)
Esempio n. 2
0
    def test_full_align(self):

        ra = RecordAligner()
        records = [Record(t1), Record(t2), Record(t3)]
        seed, mappings = ra.align(records)

        self.assertEqual(3, len(mappings))

        # all the elements from seed should matched to other 2 trees
        for tag in ['root', 'a', 'b', 'c']:
            e = seed[0].xpath('//%s' % tag)[0]
            expected = []
            for record, mapping in mappings.iteritems():
                expected.append(mapping[e].tag)
            self.assertEqual([tag] * 3, expected)
Esempio n. 3
0
    def test_align_with_record(self):

        ra = RecordAligner()
        seed_record = Record(t4)

        records = [Record(t1), Record(t2), Record(t3)]
        seed, mappings = ra.align(records, seed_record)

        self.assertEqual(4, len(mappings))

        # all the elements from seed should matched to other 3 trees
        for tag in ['root', 'a', 'b', 'c']:
            root = seed[0].xpath('//%s' % tag)[0]
            expected = []
            for record, mapping in mappings.items():
                if seed_record == record:
                    continue
                expected.append(mapping[root].tag)
            self.assertEqual([tag] * 3, expected)
Esempio n. 4
0
    def test_align_with_record(self):

        ra = RecordAligner()
        seed_record = Record(t4)

        records = [Record(t1), Record(t2), Record(t3)]
        seed, mappings = ra.align(records, seed_record)

        self.assertEqual(4, len(mappings))

        # all the elements from seed should matched to other 3 trees
        for tag in ['root', 'a', 'b', 'c']:
            root = seed[0].xpath('//%s' % tag)[0]
            expected = []
            for record, mapping in mappings.iteritems():
                if seed_record == record:
                    continue
                expected.append(mapping[root].tag)
            self.assertEqual([tag] * 3, expected)