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'))
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')
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'} })