# Path: snap/exceptions.py
# class InsufficientPermissionError(SnapError):
#     """The user does not have permission to perform the requested operation"""
# 
#     def __init__(self,message = ''):
#         SnapError.__init__(self, message)


import os
import types
import unittest
import tempfile
import snap
from snap.exceptions import InsufficientPermissionError
            snap.osregistry.OS.current_os = 'mock_windows'
        else:
            snap.osregistry.OS.current_os = 'mock'

        self.orig_target_backends = snap.config.options.target_backends
        snap.config.options.target_backends = {'repos'    : True,
                                               'packages' : True,
                                               'files'    : True,
                                               'services' : True }

        self.orig_snapfile = snap.config.options.snapfile
        self.tfile = os.path.join(tempfile.gettempdir(), "snap-test.tgz")
        snap.config.options.snapfile = self.tfile
        snap.config.options.outputformat = 'snapfile'

    def tearDown(self):
        snap.osregistry.OS.current_os = self.orig_os
        snap.config.target_backends = self.orig_target_backends
        snap.config.options.snapfile = self.orig_snapfile

    def testInsufficientPermssions(self):
        # skip until there is an easy way to change the current user w/ windows
        if snap.osregistry.OS.is_windows():
            return
       
        restoreeuid = False
        if os.geteuid() == 0:
            restoreeuid = True
            os.seteuid(1)


# Path: snap/exceptions.py
# class InsufficientPermissionError(SnapError):
#     """The user does not have permission to perform the requested operation"""
# 
#     def __init__(self,message = ''):
#         SnapError.__init__(self, message)


# Path: test/snaptest.py
import os
import types
import unittest
import tempfile
import snap
from snap.exceptions import InsufficientPermissionError

            snap.osregistry.OS.current_os = 'mock_windows'
        else:
            snap.osregistry.OS.current_os = 'mock'

        self.orig_target_backends = snap.config.options.target_backends
        snap.config.options.target_backends = {'repos'    : True,
                                               'packages' : True,
                                               'files'    : True,
                                               'services' : True }

        self.orig_snapfile = snap.config.options.snapfile
        self.tfile = os.path.join(tempfile.gettempdir(), "snap-test.tgz")
        snap.config.options.snapfile = self.tfile
        snap.config.options.outputformat = 'snapfile'

    def tearDown(self):
        snap.osregistry.OS.current_os = self.orig_os
        snap.config.target_backends = self.orig_target_backends
        snap.config.options.snapfile = self.orig_snapfile

    def testInsufficientPermssions(self):
        # skip until there is an easy way to change the current user w/ windows
        if snap.osregistry.OS.is_windows():
            return
       
        restoreeuid = False
        if os.geteuid() == 0:
            restoreeuid = True
            os.seteuid(1)


        with self.assertRaises(InsufficientPermissionError):