def test_make_path_nothing_exists(self):
        root = etree.Element('root')

        res = mp.make_path('tag1/tag2/tag3', root)

        res.shouldnt_be_none()
        res.tag.should_be('tag3')
        root.find('tag1/tag2/tag3').shouldnt_be_none()
    def test_make_path_to_parent_some_exists(self):
        root = etree.Element('root')
        t1 = etree.Element('tag1')
        root.append(t1)

        res = mp.make_path('tag1/tag2/tag3', root, to_parent=True)

        res.tag.should_be('tag2')
        t1.find('tag2').shouldnt_be_none()
    def test_make_path_with_attribs(self):
        root = etree.Element('root')

        res = mp.make_path('tag1/tag2/tag3[@name="val"]', root)

        res.shouldnt_be_none()
        res.tag.should_be('tag3')
        res.get('name').should_be('val')
        root.find('tag1/tag2/tag3').shouldnt_be_none()
    def test_make_path_parent_exists(self):
        root = etree.Element('root')
        t1 = etree.Element('tag1')
        t2 = etree.Element('tag2')
        root.append(t1)
        t1.append(t2)

        res = mp.make_path('tag1/tag2/tag3', root)

        res.tag.should_be('tag3')
        t2.find('tag3').shouldnt_be_none()
    def test_make_path_already_exists(self):
        root = etree.Element('root')
        t1 = etree.Element('tag1')
        t2 = etree.Element('tag2')
        t3 = etree.Element('tag3')
        root.append(t1)
        t1.append(t2)
        t2.append(t3)

        with mock.patch.object(mp, 'make_elem') as make_patch:
            res = mp.make_path('tag1/tag2/tag3', root)

            make_patch.called.should_be_false()
            res.tag.should_be('tag3')