Exemplo n.º 1
0
def test_migrate_one(td):
    src = pjoin(td, 'src')
    srcdir = pjoin(td, 'srcdir')
    dst = pjoin(td, 'dst')
    dstdir = pjoin(td, 'dstdir')

    touch(src, 'test file')
    touch(pjoin(srcdir, 'f'), 'test dir file')

    called = {}

    def notice_m_file(src, dst):
        called['migrate_file'] = True
        return migrate_file(src, dst)

    def notice_m_dir(src, dst):
        called['migrate_dir'] = True
        return migrate_dir(src, dst)

    with patch.object(migrate_mod, 'migrate_file', notice_m_file), \
            patch.object(migrate_mod, 'migrate_dir', notice_m_dir):
        assert migrate_one(src, dst)
        assert called == {'migrate_file': True}
        called.clear()
        assert migrate_one(srcdir, dstdir)
        assert called == {'migrate_dir': True}
        called.clear()
        assert not migrate_one(pjoin(td, 'dne'), dst)
        assert called == {}
Exemplo n.º 2
0
def test_migrate_one(td):
    src = pjoin(td, 'src')
    srcdir = pjoin(td, 'srcdir')
    dst = pjoin(td, 'dst')
    dstdir = pjoin(td, 'dstdir')
    
    touch(src, 'test file')
    touch(pjoin(srcdir, 'f'), 'test dir file')
    
    called = {}
    def notice_m_file(src, dst):
        called['migrate_file'] = True
        return migrate_file(src, dst)
    
    def notice_m_dir(src, dst):
        called['migrate_dir'] = True
        return migrate_dir(src, dst)
    
    with patch.object(migrate_mod, 'migrate_file', notice_m_file), \
            patch.object(migrate_mod, 'migrate_dir', notice_m_dir):
        assert migrate_one(src, dst)
        assert called == {'migrate_file': True}
        called.clear()
        assert migrate_one(srcdir, dstdir)
        assert called == {'migrate_dir': True}
        called.clear()
        assert not migrate_one(pjoin(td, 'dne'), dst)
        assert called == {}