Exemple #1
0
 def test_errors_are_first(self):
     validation = self.make_validation(
         ['error', 'warning', 'notice', 'error'])
     utils.limit_validation_results(validation)
     limited = validation['messages']
     assert len(limited) == 3
     assert '2 messages were truncated' in limited[0]['message']
     assert limited[1]['type'] == 'error'
     assert limited[2]['type'] == 'error'
Exemple #2
0
 def test_errors_are_first(self):
     validation = self.make_validation(
         ['error', 'warning', 'notice', 'error'])
     utils.limit_validation_results(validation)
     limited = validation['messages']
     assert len(limited) == 3
     assert '2 messages were truncated' in limited[0]['message']
     assert limited[1]['type'] == 'error'
     assert limited[2]['type'] == 'error'
Exemple #3
0
 def test_signing_severity_comes_second(self):
     validation = self.make_validation(
         ['error', 'warning', 'medium', 'notice', 'warning', 'error'])
     utils.limit_validation_results(validation)
     limited = validation['messages']
     assert len(limited) == 4
     assert '3 messages were truncated' in limited[0]['message']
     assert limited[1]['type'] == 'error'
     assert limited[2]['type'] == 'error'
     assert limited[3]['type'] == 'warning'
     assert limited[3]['signing_severity'] == 'medium'
Exemple #4
0
 def test_signing_severity_comes_second(self):
     validation = self.make_validation(
         ['error', 'warning', 'medium', 'notice', 'warning', 'error'])
     utils.limit_validation_results(validation)
     limited = validation['messages']
     assert len(limited) == 4
     assert '3 messages were truncated' in limited[0]['message']
     assert limited[1]['type'] == 'error'
     assert limited[2]['type'] == 'error'
     assert limited[3]['type'] == 'warning'
     assert limited[3]['signing_severity'] == 'medium'
Exemple #5
0
    def escaped_validation(self, is_compatibility=False):
        """
        The HTML-escaped validation results limited to a message count of
        `settings.VALIDATOR_MESSAGE_LIMIT` and optionally prepared for a
        compatibility report if `is_compatibility` is `True`.

        If `_escaped_validation` is set it will be used, otherwise
        `_escape_validation` will be called to escape the validation.
        """
        if self.validation and not self._escaped_validation:
            self._escape_validation()
        if not self._escaped_validation:
            return ""
        return limit_validation_results(json.loads(self._escaped_validation), is_compatibility=is_compatibility)
Exemple #6
0
    def escaped_validation(self, is_compatibility=False):
        """
        The HTML-escaped validation results limited to a message count of
        `settings.VALIDATOR_MESSAGE_LIMIT` and optionally prepared for a
        compatibility report if `is_compatibility` is `True`.

        If `_escaped_validation` is set it will be used, otherwise
        `_escape_validation` will be called to escape the validation.
        """
        if self.validation and not self._escaped_validation:
            self._escape_validation()
        if not self._escaped_validation:
            return ''
        return limit_validation_results(json.loads(self._escaped_validation),
                                        is_compatibility=is_compatibility)
Exemple #7
0
    def escaped_validation(self, is_compatibility=False):
        """
        The HTML-escaped validation results limited to a message count of
        `settings.VALIDATOR_MESSAGE_LIMIT` and optionally prepared for a
        compatibility report if `is_compatibility` is `True`.
        """
        if not self.validation:
            return ''

        # Import loop.
        from devhub.utils import escape_validation, limit_validation_results

        validation = json.loads(self.validation)
        return limit_validation_results(escape_validation(validation),
                                        is_compatibility=is_compatibility)