Beispiel #1
0
    def test_delete_dir_raises_oserror_when_rmtree_fails(self, mock_exists, mock_rmtree):
        """ Tests invocation of API delete_dir raises OSError when rmtree raises OSError"""
        # arrange
        dir_path = 'blah'
        mock_exists.return_value = True
        mock_rmtree.side_effect = OSError('rmtree error')

        # act, assert
        with self.assertRaises(OSError):
            Utils.delete_dir(dir_path)
Beispiel #2
0
    def test_delete_dir_when_dir_does_not_exist(self, mock_exists, mock_rmtree):
        """ Test a valid invocation of API delete_dir when dir to be deleted does not exist"""
        # arrange
        dir_path = 'blah'
        mock_exists.return_value = False

        # act
        Utils.delete_dir(dir_path)

        # assert
        mock_exists.assert_called_with(dir_path)
        mock_rmtree.assert_not_called()
Beispiel #3
0
    def test_delete_dir_when_dir_exists(self, mock_exists, mock_rmtree):
        """ Test a valid invocation of API delete_dir when dir to be deleted exists"""
        # arrange
        dir_path = 'blah'
        mock_exists.return_value = True

        # act
        Utils.delete_dir(dir_path)

        # assert
        mock_exists.assert_called_with(dir_path)
        mock_rmtree.assert_called_with(dir_path, onerror=Utils._remove_readonly_callback)