def alter_input(self, recurrence=1, reverse=False):
        """
        Altering the default return from salt to be able to test multiple
        scenarios without hardcoding
        """
        helper = OutputHelper()

        common_version = 'common_version'
        old_version = 'old_version'
        if reverse:
            common_version = 'old_version'
            old_version = 'common_version'

        expect = {
            'statusreport': [{
                'ceph': '',
                'salt': '',
                'os': ''
            }, {
                'out of sync': {}
            }]
        }

        salt_versions = helper.salt_versions
        os_codenames = helper.os_codenames
        ceph_versions = helper.ceph_versions

        tuple_data = [('salt', salt_versions), ('os', os_codenames),
                      ('ceph', ceph_versions)]

        for key, data in tuple_data:
            cv = self.versions()[key][common_version]
            ov = self.versions()[key][old_version]
            expect['statusreport'][0][key] = cv

            # if reverse, set the data to the old_values
            if reverse:
                for node, value in six.iteritems(data):
                    data[node] = data[node].replace(ov, cv)

            for count, (node, value) in enumerate(six.iteritems(data), 0):
                if count < recurrence:
                    data[node] = ov
                    if node not in expect['statusreport'][1]['out of sync']:
                        expect['statusreport'][1]['out of sync'].update(
                            {node: {}})
                    expect['statusreport'][1]['out of sync'][node].update(
                        {key: ov})

        return salt_versions, os_codenames, ceph_versions, expect
Beispiel #2
0
 def output_helper(self):
     yield OutputHelper()