示例#1
0
    def test_rm(self):
        mfpath = os.path.join(self.tmp_dir, 'manifest.yaml')

        mf = Manifest(mfpath)
        mf.add('zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
               'data/think-hires.jpg')
        mf.add('zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
               'data/think-hires2.jpg')
        self.assertTrue(
            mf.exists_keyfile(
                'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
                'data/think-hires.jpg'))
        self.assertTrue(
            mf.exists_keyfile(
                'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
                'data/think-hires2.jpg'))

        mf.rm_file('data/think-hires2.jpg')
        self.assertTrue(
            mf.exists_keyfile(
                'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
                'data/think-hires.jpg'))
        self.assertFalse(
            mf.exists_keyfile(
                'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
                'data/think-hires2.jpg'))
示例#2
0
    def test_search(self):
        mfpath = os.path.join(self.tmp_dir, 'manifest.yaml')

        mf = Manifest(mfpath)
        mf.add('zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
               'data/think-hires.jpg')
        mf.add('zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
               'data/think-hires2.jpg')
        self.assertEqual(mf.search('data/think-hires.jpg'),
                         'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u')
        self.assertEqual(mf.search('data/think-hires2.jpg'),
                         'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u')
示例#3
0
    def test_manifest_diff(self):
        mfpath = os.path.join(self.tmp_dir, 'manifest.yaml')

        mf_1 = Manifest(mfpath)
        mf_1.add('zdj7WemKEtQMVL81UU6PSuYaoxvBQ6CiUMq1fMvoXBhPUsCK2',
                 'data/image.jpg')

        mf_2 = Manifest(mfpath)
        mf_2.add('zdj7WemKEtQMVL81UU6PSuYaoxvBQ6CiUMq1fMvoXBhPUsCK2',
                 'data/image.jpg')
        mf_2.add('zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u',
                 'data/think-hires.jpg')

        mf_diff, _ = mf_1.get_diff(mf_2)

        self.assertEqual(
            mf_diff, {
                'zdj7WgHSKJkoJST5GWGgS53ARqV7oqMGYVvWzEWku3MBfnQ9u':
                {'data/think-hires.jpg'}
            })