def test_administrator_no_win32api_and_windows(self): self.assertEqual(ctypes.windll.shell32.IsUserAnAdmin() != 0, user.is_administrator())
def test_administrator_getuid(self): self.assertEqual(getuid() == 0, user.is_administrator())
def test_administrator_win32api(self): self.assertEqual(shell.IsUserAnAdmin(), user.is_administrator())
from mock import Mock, patch from twisted.internet.error import ProcessTerminated, ProcessDone from twisted.python.failure import Failure from voluptuous import Schema, MultipleInvalid from pyfarm.core.utility import ImmutableDict from pyfarm.core.enums import INTEGER_TYPES, STRING_TYPES, WINDOWS from pyfarm.agent.config import config from pyfarm.agent.testutil import TestCase, skipIf from pyfarm.agent.sysinfo.user import is_administrator from pyfarm.jobtypes.core.internals import USER_GROUP_TYPES from pyfarm.jobtypes.core.jobtype import ( JobType, CommandData, process_stdout, process_stderr, logger) from pyfarm.jobtypes.core.log import STDOUT, STDERR, logpool IS_ADMIN = is_administrator() def fake_assignment(): assignment_id = uuid4() assignment = { "id": assignment_id, "job": { "id": 1, "by": 1, "title": "Hello World", "data": {"a": True, "b": False, "c": None, "d": 1}}, "jobtype": { "name": "Foo", "version": 1}, "tasks": [{"id": 1, "frame": 1, "attempt": 1},