コード例 #1
0
ファイル: test_heat_client.py プロジェクト: dwcramer/otter
    def test_update_stack(self):
        """
        update_stack PUTs data to the stack endpoint and returns
        the parsed JSON result.
        """
        log = mock_log()
        treq = self._treq(code=202, method='put',
                          json_content={'hello': 'world'})
        client = HeatClient('my-auth-token', log, treq)
        result = client.update_stack(
            'http://heat-url/my-stack', {'p1': 'v1'}, 60,
            'my template')
        treq.put.assert_called_once_with(
            'http://heat-url/my-stack',
            headers={'x-auth-token': ['my-auth-token'],
                     'content-type': ['application/json'],
                     'accept': ['application/json'],
                     'User-Agent': ['OtterScale/0.0']},
            data=json.dumps({
                'parameters': {'p1': 'v1'},
                'timeout_mins': 60,
                'template': 'my template'}),
            log=mock.ANY)

        self.assertEqual(self.successResultOf(result), {'hello': 'world'})
        self._assert_bound(log, treq.put.mock_calls[-1][2]['log'],
                           system='heatclient', event='update-stack')
コード例 #2
0
ファイル: test_heat_client.py プロジェクト: dwcramer/otter
 def test_get_stack(self):
     """get_stack performs a GET on the given stack URL."""
     log = mock_log()
     treq = self._treq(code=200, method='get',
                       json_content={'hello': 'world'})
     client = HeatClient('my-auth-token', log, treq)
     result = client.get_stack('http://heat-url/my-stack')
     self.assertEqual(self.successResultOf(result), {'hello': 'world'})
コード例 #3
0
ファイル: test_heat_client.py プロジェクト: dwcramer/otter
 def test_get_stack_error(self):
     """Non-200 codes from getting a stack are considered an APIError."""
     log = mock_log()
     treq = self._treq(code=201, method='get',
                       json_content={'hello': 'world'})
     client = HeatClient('my-auth-token', log, treq)
     result = client.get_stack('http://heat-url/my-stack')
     failure = self.failureResultOf(result)
     failure.trap(APIError)
コード例 #4
0
ファイル: test_heat_client.py プロジェクト: dwcramer/otter
 def test_update_stack_error(self):
     """Non-202 codes from updating a stack are considered an APIError."""
     log = mock_log()
     treq = self._treq(code=204, method='put',
                       json_content={'hello': 'world'})
     client = HeatClient('my-auth-token', log, treq)
     result = client.update_stack(
         'http://heat-url/my-stack', {'p1': 'v1'}, 60,
         'my template')
     failure = self.failureResultOf(result)
     failure.trap(APIError)
コード例 #5
0
ファイル: test_heat_client.py プロジェクト: dwcramer/otter
 def test_create_stack_error(self):
     """
     On any result other than 201, create_stack raises an exception.
     """
     log = mock_log()
     treq = self._treq(code=404, method='post',
                       json_content={'hello': 'world'})
     client = HeatClient('my-auth-token', log, treq)
     result = client.create_stack(
         'http://heat-url/', 'my-stack-name', {'p1': 'v1'}, 60,
         'my template')
     failure = self.failureResultOf(result)
     failure.trap(APIError)