class TestLocalFileAccessLayer(unittest.TestCase):
    def setUp(self):
        # make some files and dir under /tmp
        self.workdir="/tmp/test_pygranule"

        os.mkdir(self.workdir)
        os.mkdir(self.workdir+"/testdir1")
        os.mkdir(self.workdir+"/testdir2")
        make_dummy_file(self.workdir+"/file1")
        make_dummy_file(self.workdir+"/file2")
        make_dummy_file(self.workdir+"/file3")
        make_dummy_file(self.workdir+"/testdir1/file4")
        make_dummy_file(self.workdir+"/testdir1/filetoremove")

        # instance
        self.fal = LocalFileAccessLayer()

    def tearDown(self):
        shutil.rmtree(self.workdir)

    def test_list_source_directory(self):
        files = self.fal.list_source_directory(self.workdir)
        self.assertItemsEqual(files,[self.workdir+'/file1',self.workdir+'/file2',self.workdir+'/file3'])

    def test_copy_file(self):
        self.fal.copy_file(self.workdir+"/file1",self.workdir+"/testdir2/file5")
        self.assertItemsEqual( os.listdir(self.workdir+"/testdir2"), ['file5'])

    def test_remove_source_file(self):
        self.fal.remove_source_file(self.workdir+"/testdir1/filetoremove")
        self.assertItemsEqual( os.listdir(self.workdir+"/testdir1"), ['file4'] )
Пример #2
0
 def setUp(self):
     # instance
     self.fal = LocalFileAccessLayer()
     # mock
     self.fal.os.listdir = Mock(return_value=['file1', 'file2', 'file3'])
     self.fal.os.path.isfile = Mock(return_value=True)
     self.fal.os.path.isdir = Mock()
     self.fal.os.makedirs = Mock(return_value=True)
     self.fal.shutil.copyfile = Mock()
Пример #3
0
    def setUp(self):
        # make some files and dir under /tmp
        self.workdir = "/tmp/test_pygranule"

        os.mkdir(self.workdir)
        os.mkdir(self.workdir + "/testdir1")
        os.mkdir(self.workdir + "/testdir2")
        make_dummy_file(self.workdir + "/file1")
        make_dummy_file(self.workdir + "/file2")
        make_dummy_file(self.workdir + "/file3")
        make_dummy_file(self.workdir + "/testdir1/file4")
        make_dummy_file(self.workdir + "/testdir1/filetoremove")

        # instance
        self.fal = LocalFileAccessLayer()
 def setUp(self):
     # instance
     self.fal = LocalFileAccessLayer()
     # mock
     self.fal.os.listdir = Mock(return_value=['file1','file2','file3'])
     self.fal.os.path.isfile = Mock(return_value=True)
     self.fal.os.path.isdir = Mock()
     self.fal.os.makedirs = Mock(return_value=True)
     self.fal.shutil.copyfile = Mock()
class TestLocalFileAccessLayer(unittest.TestCase):
    def setUp(self):
        # instance
        self.fal = LocalFileAccessLayer()
        # mock
        self.fal.os.listdir = Mock(return_value=['file1','file2','file3'])
        self.fal.os.path.isfile = Mock(return_value=True)
        self.fal.os.path.isdir = Mock()
        self.fal.os.makedirs = Mock(return_value=True)
        self.fal.shutil.copyfile = Mock()

    def tearDown(self):
        pass

    def test_list_source_directory(self):
        files = self.fal.list_source_directory('/somedir')
        self.assertItemsEqual(files,['/somedir/file1','/somedir/file2','/somedir/file3'])

    def test_copy_file(self):
        self.assertIsNone( self.fal.copy_file("/somedir/file1","/somedir/file5") )
Пример #6
0
class TestLocalFileAccessLayer(unittest.TestCase):
    def setUp(self):
        # instance
        self.fal = LocalFileAccessLayer()
        # mock
        self.fal.os.listdir = Mock(return_value=['file1', 'file2', 'file3'])
        self.fal.os.path.isfile = Mock(return_value=True)
        self.fal.os.path.isdir = Mock()
        self.fal.os.makedirs = Mock(return_value=True)
        self.fal.shutil.copyfile = Mock()

    def tearDown(self):
        pass

    def test_list_source_directory(self):
        files = self.fal.list_source_directory('/somedir')
        self.assertItemsEqual(
            files, ['/somedir/file1', '/somedir/file2', '/somedir/file3'])

    def test_copy_file(self):
        self.assertIsNone(
            self.fal.copy_file("/somedir/file1", "/somedir/file5"))
Пример #7
0
class TestLocalFileAccessLayer(unittest.TestCase):
    def setUp(self):
        # make some files and dir under /tmp
        self.workdir = "/tmp/test_pygranule"

        os.mkdir(self.workdir)
        os.mkdir(self.workdir + "/testdir1")
        os.mkdir(self.workdir + "/testdir2")
        make_dummy_file(self.workdir + "/file1")
        make_dummy_file(self.workdir + "/file2")
        make_dummy_file(self.workdir + "/file3")
        make_dummy_file(self.workdir + "/testdir1/file4")
        make_dummy_file(self.workdir + "/testdir1/filetoremove")

        # instance
        self.fal = LocalFileAccessLayer()

    def tearDown(self):
        shutil.rmtree(self.workdir)

    def test_list_source_directory(self):
        files = self.fal.list_source_directory(self.workdir)
        self.assertItemsEqual(files, [
            self.workdir + '/file1', self.workdir + '/file2',
            self.workdir + '/file3'
        ])

    def test_copy_file(self):
        self.fal.copy_file(self.workdir + "/file1",
                           self.workdir + "/testdir2/file5")
        self.assertItemsEqual(os.listdir(self.workdir + "/testdir2"),
                              ['file5'])

    def test_remove_source_file(self):
        self.fal.remove_source_file(self.workdir + "/testdir1/filetoremove")
        self.assertItemsEqual(os.listdir(self.workdir + "/testdir1"),
                              ['file4'])
    def setUp(self):
        # make some files and dir under /tmp
        self.workdir="/tmp/test_pygranule"

        os.mkdir(self.workdir)
        os.mkdir(self.workdir+"/testdir1")
        os.mkdir(self.workdir+"/testdir2")
        make_dummy_file(self.workdir+"/file1")
        make_dummy_file(self.workdir+"/file2")
        make_dummy_file(self.workdir+"/file3")
        make_dummy_file(self.workdir+"/testdir1/file4")
        make_dummy_file(self.workdir+"/testdir1/filetoremove")

        # instance
        self.fal = LocalFileAccessLayer()