コード例 #1
0
ファイル: transfer_test.py プロジェクト: tristan0x/shifter
    def test_copyfile_invalid(self):
        tmp_path = tempfile.mkdtemp()
        self.system['local']['imageDir'] = tmp_path
        self.system['ssh']['imageDir'] = tmp_path

        self.system['accesstype'] = 'invalid'

        with self.assertRaises(NotImplementedError):
            transfer.copy_file(__file__, self.system)

        os.rmdir(tmp_path)
コード例 #2
0
    def test_copyfile_invalid(self):
        tmpPath = tempfile.mkdtemp() 
        self.system['local']['imageDir'] = tmpPath
        self.system['ssh']['imageDir'] = tmpPath
       
        self.system['accesstype'] = 'invalid'
     
        with self.assertRaises(NotImplementedError):
            transfer.copy_file(__file__, self.system)

        os.rmdir(tmpPath)
コード例 #3
0
    def test_copyfile_failtowrite(self):
        tmpPath = tempfile.mkdtemp() 
        self.system['local']['imageDir'] = tmpPath
        self.system['ssh']['imageDir'] = tmpPath
       
        self.system['accesstype'] = 'local'

        # make directory unwritable
        os.chmod(tmpPath, 0555)
        with self.assertRaises(OSError):
            transfer.copy_file(__file__, self.system)

        self.inodes = 0
        os.path.walk(tmpPath, self.inodeCounter, None)
        assert self.inodes == 0
        os.rmdir(tmpPath)
コード例 #4
0
ファイル: transfer_test.py プロジェクト: tristan0x/shifter
    def test_copyfile_failtowrite(self):
        tmp_path = tempfile.mkdtemp()
        self.system['local']['imageDir'] = tmp_path
        self.system['ssh']['imageDir'] = tmp_path

        self.system['accesstype'] = 'local'

        # make directory unwritable
        os.chmod(tmp_path, 0555)
        with self.assertRaises(OSError):
            transfer.copy_file(__file__, self.system)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        assert self.inodes == 0
        os.rmdir(tmp_path)
コード例 #5
0
    def test_copyfile_local(self):
        tmpPath = tempfile.mkdtemp() 
        self.system['local']['imageDir'] = tmpPath
        self.system['ssh']['imageDir'] = tmpPath
       
        self.system['accesstype'] = 'local'
        transfer.copy_file(__file__, self.system)
        dir,fname = os.path.split(__file__)
        filePath = os.path.join(tmpPath, fname)
        assert os.path.exists(filePath)

        self.inodes = 0
        os.path.walk(tmpPath, self.inodeCounter, None)
        assert self.inodes == 1
        os.unlink(filePath)

        self.inodes = 0
        os.path.walk(tmpPath, self.inodeCounter, None)
        assert self.inodes == 0

        os.rmdir(tmpPath)
コード例 #6
0
ファイル: transfer_test.py プロジェクト: tristan0x/shifter
    def test_copyfile_local(self):
        tmp_path = tempfile.mkdtemp()
        self.system['local']['imageDir'] = tmp_path
        self.system['ssh']['imageDir'] = tmp_path

        self.system['accesstype'] = 'local'
        transfer.copy_file(__file__, self.system)
        fname = os.path.split(__file__)[1]
        file_path = os.path.join(tmp_path, fname)
        assert os.path.exists(file_path)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        assert self.inodes == 1
        os.unlink(file_path)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        assert self.inodes == 0

        os.rmdir(tmp_path)
コード例 #7
0
ファイル: transfer_test.py プロジェクト: NERSC/shifter
    def test_copyfile_local(self):
        tmp_path = tempfile.mkdtemp()
        self.system['local']['imageDir'] = tmp_path
        self.system['ssh']['imageDir'] = tmp_path

        self.system['accesstype'] = 'local'
        transfer.copy_file(__file__, self.system)
        fname = os.path.split(__file__)[1]
        file_path = os.path.join(tmp_path, fname)
        self.assertTrue(os.path.exists(file_path))

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        self.assertEquals(self.inodes, 1)
        os.unlink(file_path)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        self.assertEquals(self.inodes, 0)

        os.rmdir(tmp_path)
コード例 #8
0
    def test_copyfile_remote(self):
        """uses mock ssh/scp wrapper to pretend to do the remote
           transfer, ensure it is in PATH prior to running test
        """
        tmpPath = tempfile.mkdtemp() 
        self.system['local']['imageDir'] = tmpPath
        self.system['ssh']['imageDir'] = tmpPath
       
        self.system['accesstype'] = 'remote'
        transfer.copy_file(__file__, self.system)
        dir,fname = os.path.split(__file__)
        filePath = os.path.join(tmpPath, fname)
        assert os.path.exists(filePath)

        self.inodes = 0
        os.path.walk(tmpPath, self.inodeCounter, None)
        assert self.inodes == 1
        os.unlink(filePath)

        self.inodes = 0
        os.path.walk(tmpPath, self.inodeCounter, None)
        assert self.inodes == 0

        os.rmdir(tmpPath)
コード例 #9
0
ファイル: transfer_test.py プロジェクト: tristan0x/shifter
    def test_copyfile_remote(self):
        """uses mock ssh/scp wrapper to pretend to do the remote
           transfer, ensure it is in PATH prior to running test
        """
        tmp_path = tempfile.mkdtemp()
        self.system['local']['imageDir'] = tmp_path
        self.system['ssh']['imageDir'] = tmp_path

        self.system['accesstype'] = 'remote'
        transfer.copy_file(__file__, self.system)
        fname = os.path.split(__file__)[1]
        file_path = os.path.join(tmp_path, fname)
        assert os.path.exists(file_path)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        assert self.inodes == 1
        os.unlink(file_path)

        self.inodes = 0
        os.path.walk(tmp_path, self.inode_counter, None)
        assert self.inodes == 0

        os.rmdir(tmp_path)