Beispiel #1
0
    def show_validations(self, validation,
                         log_path=constants.VALIDATIONS_LOG_BASEDIR):
        """Display detailed information about a Validation

        :param validation: The name of the validation
        :type validation: `string`
        :param log_path: The absolute path of the validations logs
        :type log_path: `string`

        :return: The detailed information for a validation
        :rtype: `dict`

        :Example:

        >>> path = "/foo/bar"
        >>> validation = 'foo'
        >>> action = ValidationActions(validation_path=path)
        >>> results = action.show_validations(validation=validation)
        >>> print(results)
        {
         'Description': 'Description of the foo validation',
         'Groups': ['group1', 'group2'],
         'ID': 'foo',
         'Last execution date': None,
         'Name': 'Name of the validation foo',
         'Number of execution': 'Total: 0, Passed: 0, Failed: 0',
         'Parameters': {'foo1': bar1}
        }
        """
        self.log = logging.getLogger(__name__ + ".show_validations")
        # Get validation data:
        vlog = ValidationLogs(log_path)
        data = v_utils.get_validations_data(validation, self.validation_path)
        if not data:
            msg = "Validation {} not found in the path: {}".format(
                validation,
                self.validation_path)
            raise RuntimeError(msg)
        logfiles = vlog.get_logfile_content_by_validation(validation)
        data_format = vlog.get_validations_stats(logfiles)
        data.update(data_format)
        return data
Beispiel #2
0
 def test_get_validations_stats(self, mock_open, mock_json):
     vlogs = ValidationLogs('/tmp/foo')
     content = vlogs.get_validations_stats(
         fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
     self.assertEqual(content, fakes.VALIDATIONS_STATS)