Ejemplo n.º 1
0
 def test_error_message(self, plugin, message, expected_error_message):
     plugins_metadata = json.dumps({
         'errors': {
             plugin: message,
         },
     })
     if not plugin:
         plugins_metadata = ''
     build_response = BuildResponse({
         'metadata': {
             'annotations': {
                 'plugins-metadata': plugins_metadata
             }
         }
     })
     assert build_response.get_error_message() == expected_error_message
Ejemplo n.º 2
0
 def test_error_message(self, plugin, message, expected_error_message):
     plugins_metadata = json.dumps({
         'errors': {
             plugin: message,
         },
     })
     if not plugin:
         plugins_metadata = ''
     build_response = BuildResponse({
         'metadata': {
             'annotations': {
                 'plugins-metadata': plugins_metadata
             }
         }
     })
     assert build_response.get_error_message() == expected_error_message
    def test_error_message(self, osbs, pod, plugin, message,
                           expected_error_message):
        class MockOsbsPod:
            def __init__(self, error):
                self.error = error

            def get_pod_for_build(self, build_id):
                return self

            def get_failure_reason(self):
                if self.error:
                    return self.error
                raise OsbsException

        if pod or osbs:
            mock_pod = MockOsbsPod(pod)
        else:
            mock_pod = None
        if plugin:
            plugins_metadata = json.dumps({
                'errors': {
                    plugin: message,
                },
            })
            build = {
                'metadata': {
                    'annotations': {
                        'plugins-metadata': plugins_metadata,
                    },
                },
            }
        else:
            build = {
                'metadata': {
                    'annotations': {},
                },
            }

        build_response = BuildResponse(build, mock_pod)

        assert build_response.get_error_message() == expected_error_message