コード例 #1
0
    def setUp(self):

        MockerTestCase.setUp(self)

        self.data = {
            "handlercount": 0,
            "frequency": "",
            "handlerdir": self.makeDir(),
            "handlers": helpers.ContentHandlers(),
            "data": None}

        self.expected_module_name = "part-handler-%03d" % (
            self.data["handlercount"],)
        expected_file_name = "%s.py" % self.expected_module_name
        expected_file_fullname = os.path.join(self.data["handlerdir"],
                                              expected_file_name)
        self.module_fake = FakeModule()
        self.ctype = None
        self.filename = None
        self.payload = "dummy payload"

        # Mock the write_file function
        write_file_mock = self.mocker.replace(util.write_file,
                                              passthrough=False)
        write_file_mock(expected_file_fullname, self.payload, 0600)
コード例 #2
0
    def setUp(self):

        MockerTestCase.setUp(self)

        self.data = {
            "handlercount": 0,
            "frequency": "",
            "handlerdir": self.makeDir(),
            "handlers": helpers.ContentHandlers(),
            "data": None
        }

        self.expected_module_name = "part-handler-%03d" % (
            self.data["handlercount"], )
        expected_file_name = "%s.py" % self.expected_module_name
        expected_file_fullname = os.path.join(self.data["handlerdir"],
                                              expected_file_name)
        self.module_fake = FakeModule()
        self.ctype = None
        self.filename = None
        self.payload = "dummy payload"

        # Mock the write_file function
        write_file_mock = self.mocker.replace(util.write_file,
                                              passthrough=False)
        write_file_mock(expected_file_fullname, self.payload, 0600)
コード例 #3
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')
コード例 #4
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')
コード例 #5
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')

        self.stream = StringIO()
        self.handler = StreamHandler(self.stream)
        self.handler.setFormatter(Formatter('%(levelname)s %(message)s'))
        LOG.addHandler(self.handler)
        self.ori_log_level = LOG.getEffectiveLevel()
        LOG.setLevel(DEBUG)
コード例 #6
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')

        self.stream = StringIO()
        self.handler = StreamHandler(self.stream)
        self.handler.setFormatter(Formatter('%(levelname)s %(message)s'))
        LOG.addHandler(self.handler)
        self.ori_log_level = LOG.getEffectiveLevel()
        LOG.setLevel(DEBUG)
コード例 #7
0
ファイル: helpers.py プロジェクト: phobos182/cloud-init
 def __init__(self, methodName="runTest"):
     MockerTestCase.__init__(self, methodName)
     self.resource_path = None
コード例 #8
0
 def __init__(self, methodName="runTest"):
     MockerTestCase.__init__(self, methodName)
     self.resource_path = None
コード例 #9
0
 def tearDown(self):
     MockerTestCase.tearDown(self)
     sys.stdout = self.saved_stdout
     sys.stderr = self.saved_stderr
コード例 #10
0
 def setUp(self):
     MockerTestCase.setUp(self)
     self.saved_stdout = sys.stdout
     sys.stdout = StringIO.StringIO()
     self.saved_stderr = sys.stderr
     sys.stderr = StringIO.StringIO()
コード例 #11
0
    def setUp(self):
        MockerTestCase.setUp(self)

        self.requests = self.mocker.replace('requests')
        # this mocks any unexpected request:
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)
コード例 #12
0
    def setUp(self):
        MockerTestCase.setUp(self)

        self.requests = self.mocker.replace('requests')
        # this mocks any unexpected request:
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)