import os

from dvc.cache import Cache

from tests.basic_env import TestDvc


class TestCache(TestDvc):
    def setUp(self):
        super(TestCache, self).setUp()
        self.cache1 = os.path.join(self.dvc.cache.cache_dir, '1')
        self.cache2 = os.path.join(self.dvc.cache.cache_dir, '2')
        self.create(self.cache1, '1')
        self.create(self.cache2, '2')

    def test_all(self):
        flist = Cache(self.dvc.dvc_dir).all()
        self.assertEquals(len(flist), 2)
        self.assertTrue(self.cache1 in flist)
        self.assertTrue(self.cache2 in flist)

    def test_get(self):
        cache = Cache(self.dvc.dvc_dir).get(os.path.basename(self.cache1))
        self.assertEquals(cache, self.cache1)

@@ -31,16 +31,46 @@
 rt Cache
+%0Afrom dvc.system import System
 %0A%0Afrom t
@@ -745,8 +745,535 @@
 cache1)%0A
+%0A    def test_find_cache(self):%0A        fname1 = os.path.basename(self.cache1)%0A        fname1_md5 = fname1%0A        fname2 = os.path.basename(self.cache2)%0A        fname2_md5 = fname2%0A        fname3 = 'non_existing'%0A%0A        System.hardlink(self.cache1, fname1)%0A        System.hardlink(self.cache2, fname2)%0A%0A        cache = Cache(self.dvc.dvc_dir).find_cache(%5Bfname1, fname2, fname3%5D)%0A%0A        expected = %7Bfname1: fname1_md5, fname2: fname2_md5%7D%0A%0A        self.assertEqual(len(cache), 2)%0A        self.assertEqual(cache, expected)%0A

add test for Cache.find_cache()