Exemple #1
0
    def results_store(self, workdir):
        data = {'old': {'patches_full': {0: ['mytest.patch', '-p1', 0],
                                         1: ['mytest2.patch', '-p1', 1]},
                        'srpm': './test-1.2.0-1.src.rpm',
                        'rpm': ['./test-1.2.0-1.x86_64.rpm', './test-devel-1.2.0-1.x86_64.rpm'],
                        'logs': ['logfile1.log', 'logfile2.log']
                        },
                'new': {'patches_full': {0: ['mytest.patch', 0, '-p1'],
                                         1: ['mytest2.patch', 1, '-p1']},
                        'srpm': './test-1.2.2-1.src.rpm',
                        'rpm': ['./test-1.2.2-1.x86_64.rpm', './test-devel-1.2.2-1.x86_64.rpm'],
                        'logs': ['logfile3.log', 'logfile4.log']},
                'patches': {'deleted': ['mytest2.patch']},
                'results_dir': workdir,
                'moved': ['/usr/sbin/test', '/usr/sbin/test2'],
                'success': 'Success',
                }

        rs = ResultsStore()
        rs.set_build_data('old', data['old'])
        rs.set_build_data('new', data['new'])
        rs.set_patches_results(data['patches'])
        rs.set_checker_output('pkgdiff', {'path': 'rebase-helper-results/checkers/pkgdiff'})
        files_build_log_hook_result = {
            'removed': {'%files': ['README']}
        }
        rs.set_build_log_hooks_result('files', files_build_log_hook_result)
        rs.set_info_text('Information text', 'some information text')
        rs.set_info_text('Next Information', 'some another information text')
        rs.set_result_message('success', data['success'])

        return rs
Exemple #2
0
    def results_store(self, workdir):
        data = {
            'old': {
                'patches_full': {
                    0: ['mytest.patch', '-p1', 0],
                    1: ['mytest2.patch', '-p1', 1]
                },
                'srpm':
                './test-1.2.0-1.src.rpm',
                'rpm': [
                    './test-1.2.0-1.x86_64.rpm',
                    './test-devel-1.2.0-1.x86_64.rpm'
                ],
                'logs': ['logfile1.log', 'logfile2.log']
            },
            'new': {
                'patches_full': {
                    0: ['mytest.patch', 0, '-p1'],
                    1: ['mytest2.patch', 1, '-p1']
                },
                'srpm':
                './test-1.2.2-1.src.rpm',
                'rpm': [
                    './test-1.2.2-1.x86_64.rpm',
                    './test-devel-1.2.2-1.x86_64.rpm'
                ],
                'logs': ['logfile3.log', 'logfile4.log']
            },
            'patches': {
                'deleted': ['mytest2.patch']
            },
            'results_dir': workdir,
            'moved': ['/usr/sbin/test', '/usr/sbin/test2'],
            'success': 'Success',
        }

        rs = ResultsStore()
        rs.set_build_data('old', data['old'])
        rs.set_build_data('new', data['new'])
        rs.set_patches_results(data['patches'])
        message = 'Following files were moved\n%s\n' % '\n'.join(data['moved'])
        test_output = {'pkgdiff': message}
        rs.set_checker_output('Results from checker(s)', test_output)
        rs.set_info_text('Information text', 'some information text')
        rs.set_info_text('Next Information', 'some another information text')
        rs.set_result_message('success', data['success'])

        return rs
Exemple #3
0
class TestOutputTool(BaseTest):
    """
    Class is used for testing OutputTool and other BaseOutputTool based classes
    """
    def setup(self):
        super(TestOutputTool, self).setup()

        data = {
            'old': {
                'patches_full': {
                    0: ['mytest.patch', '-p1', 0],
                    1: ['mytest2.patch', '-p1', 1]
                },
                'srpm':
                './test-1.2.0-1.src.rpm',
                'rpm': [
                    './test-1.2.0-1.x86_64.rpm',
                    './test-devel-1.2.0-1.x86_64.rpm'
                ],
                'logs': ['logfile1.log', 'logfile2.log']
            },
            'new': {
                'patches_full': {
                    0: ['mytest.patch', 0, '-p1'],
                    1: ['mytest2.patch', 1, '-p1']
                },
                'srpm':
                './test-1.2.2-1.src.rpm',
                'rpm': [
                    './test-1.2.2-1.x86_64.rpm',
                    './test-devel-1.2.2-1.x86_64.rpm'
                ],
                'logs': ['logfile3.log', 'logfile4.log']
            },
            'patches': {
                'deleted': ['mytest2.patch']
            },
            'results_dir': self.WORKING_DIR,
            'moved': ['/usr/sbin/test', '/usr/sbin/test2'],
        }

        self.results_store = ResultsStore()
        self.results_store.set_build_data('old', data['old'])
        self.results_store.set_build_data('new', data['new'])
        self.results_store.set_patches_results(data['patches'])
        message = 'Following files were moved\n%s\n' % '\n'.join(data['moved'])
        test_output = {'pkgdiff': message}
        self.results_store.set_checker_output('Results from checker(s)',
                                              test_output)
        self.results_store.set_info_text('Information text',
                                         'some information text')
        self.results_store.set_info_text('Next Information',
                                         'some another information text')

        self.results_file_path = os.path.join(self.WORKING_DIR, 'output_file')

    def get_expected_text_output(self):
        expected_output = """
Summary information about patches:
Patch mytest2.patch [deleted]

Old (S)RPM packages:
---------------------
SRPM package(s): are in directory . :
- test-1.2.0-1.src.rpm
RPM package(s): are in directory . :
- test-1.2.0-1.x86_64.rpm
- test-devel-1.2.0-1.x86_64.rpm
Available Old logs:
- logfile1.log
- logfile2.log

New (S)RPM packages:
---------------------
SRPM package(s): are in directory . :
- test-1.2.2-1.src.rpm
RPM package(s): are in directory . :
- test-1.2.2-1.x86_64.rpm
- test-devel-1.2.2-1.x86_64.rpm
Available New logs:
- logfile3.log
- logfile4.log
=== Checker Results from checker(s) results ===
Following files were moved
/usr/sbin/test
/usr/sbin/test2
See for more details pkgdiff"""
        return expected_output

    @staticmethod
    def get_expected_json_output():
        expected_output = {
            ResultsStore.RESULTS_BUILDS: {
                "new": {
                    "logs": ["logfile3.log", "logfile4.log"],
                    "patches_full": {
                        "0": ["mytest.patch", 0, "-p1"],
                        "1": ["mytest2.patch", 1, "-p1"]
                    },
                    "rpm": [
                        "./test-1.2.2-1.x86_64.rpm",
                        "./test-devel-1.2.2-1.x86_64.rpm"
                    ],
                    "srpm":
                    "./test-1.2.2-1.src.rpm"
                },
                "old": {
                    "logs": ["logfile1.log", "logfile2.log"],
                    "patches_full": {
                        "0": ["mytest.patch", "-p1", 0],
                        "1": ["mytest2.patch", "-p1", 1]
                    },
                    "rpm": [
                        "./test-1.2.0-1.x86_64.rpm",
                        "./test-devel-1.2.0-1.x86_64.rpm"
                    ],
                    "srpm":
                    "./test-1.2.0-1.src.rpm"
                }
            },
            ResultsStore.RESULTS_CHECKERS: {
                "Results from checker(s)": {
                    "pkgdiff":
                    "Following files were moved\n/usr/sbin/test\n/usr/sbin/test2\n"
                }
            },
            ResultsStore.RESULTS_INFORMATION: {
                "Information text": "some information text",
                "Next Information": "some another information text"
            },
            ResultsStore.RESULTS_PATCHES: {
                "deleted": ["mytest2.patch"]
            }
        }
        return expected_output

    def test_text_output_tool(self):
        output = OutputTool('text')
        output.print_information(self.results_file_path, self.results_store)

        with open(self.results_file_path) as f:
            lines = [y.strip() for y in f.readlines()]
            assert lines == self.get_expected_text_output().split('\n')

    def test_json_output_tool(self):
        output = OutputTool('json')
        output.print_information(self.results_file_path, self.results_store)

        with open(self.results_file_path) as f:
            json_dict = json.load(f, encoding='utf-8')
            # in Python2 strings in json decoded dict are Unicode, which would make the test fail
            assert json_dict == json.loads(
                json.dumps(self.get_expected_json_output()))
Exemple #4
0
class TestOutputTool(BaseTest):
    """
    Class is used for testing OutputTool and other BaseOutputTool based classes
    """

    def setup(self):
        super(TestOutputTool, self).setup()

        data = {'old': {'patches_full': {0: ['mytest.patch', '-p1', 0],
                                         1: ['mytest2.patch', '-p1', 1]},
                        'srpm': './test-1.2.0-1.src.rpm',
                        'rpm': ['./test-1.2.0-1.x86_64.rpm', './test-devel-1.2.0-1.x86_64.rpm'],
                        'logs': ['logfile1.log', 'logfile2.log']
                        },
                'new': {'patches_full': {0: ['mytest.patch', 0, '-p1'],
                                         1: ['mytest2.patch', 1, '-p1']},
                        'srpm': './test-1.2.2-1.src.rpm',
                        'rpm': ['./test-1.2.2-1.x86_64.rpm', './test-devel-1.2.2-1.x86_64.rpm'],
                        'logs': ['logfile3.log', 'logfile4.log']},
                'patches': {'deleted': ['mytest2.patch']},
                'results_dir': self.WORKING_DIR,
                'moved': ['/usr/sbin/test', '/usr/sbin/test2'],
                }

        self.results_store = ResultsStore()
        self.results_store.set_build_data('old', data['old'])
        self.results_store.set_build_data('new', data['new'])
        self.results_store.set_patches_results(data['patches'])
        message = 'Following files were moved\n%s\n' % '\n'.join(data['moved'])
        test_output = {'pkgdiff': message}
        self.results_store.set_checker_output('Results from checker(s)', test_output)
        self.results_store.set_info_text('Information text', 'some information text')
        self.results_store.set_info_text('Next Information', 'some another information text')

        self.results_file_path = os.path.join(self.WORKING_DIR, 'output_file')

    def get_expected_text_output(self):
        expected_output = """
Summary information about patches:
Patch mytest2.patch [deleted]

Old (S)RPM packages:
---------------------
SRPM package(s): are in directory . :
- test-1.2.0-1.src.rpm
RPM package(s): are in directory . :
- test-1.2.0-1.x86_64.rpm
- test-devel-1.2.0-1.x86_64.rpm
Available Old logs:
- logfile1.log
- logfile2.log

New (S)RPM packages:
---------------------
SRPM package(s): are in directory . :
- test-1.2.2-1.src.rpm
RPM package(s): are in directory . :
- test-1.2.2-1.x86_64.rpm
- test-devel-1.2.2-1.x86_64.rpm
Available New logs:
- logfile3.log
- logfile4.log
=== Checker Results from checker(s) results ===
Following files were moved
/usr/sbin/test
/usr/sbin/test2
See for more details pkgdiff"""
        return expected_output

    @staticmethod
    def get_expected_json_output():
        expected_output = {
            ResultsStore.RESULTS_BUILDS: {
                "new": {
                    "logs": ["logfile3.log", "logfile4.log"],
                    "patches_full": {
                        "0": ["mytest.patch", 0, "-p1"],
                        "1": ["mytest2.patch", 1, "-p1"]
                    },
                    "rpm": ["./test-1.2.2-1.x86_64.rpm", "./test-devel-1.2.2-1.x86_64.rpm"],
                    "srpm": "./test-1.2.2-1.src.rpm"
                },
                "old": {
                    "logs": ["logfile1.log", "logfile2.log"],
                    "patches_full": {
                        "0": ["mytest.patch", "-p1", 0],
                        "1": ["mytest2.patch", "-p1", 1]
                    },
                    "rpm": ["./test-1.2.0-1.x86_64.rpm", "./test-devel-1.2.0-1.x86_64.rpm"],
                    "srpm": "./test-1.2.0-1.src.rpm"
                }
            },
            ResultsStore.RESULTS_CHECKERS: {
                "Results from checker(s)": {
                    "pkgdiff": "Following files were moved\n/usr/sbin/test\n/usr/sbin/test2\n"
                }
            },
            ResultsStore.RESULTS_INFORMATION: {
                "Information text": "some information text",
                "Next Information": "some another information text"
            },
            ResultsStore.RESULTS_PATCHES: {
                "deleted": ["mytest2.patch"]
            }
        }
        return expected_output

    def test_text_output_tool(self):
        output = OutputTool('text')
        output.print_information(self.results_file_path, self.results_store)

        with open(self.results_file_path) as f:
            lines = [y.strip() for y in f.readlines()]
            assert lines == self.get_expected_text_output().split('\n')

    def test_json_output_tool(self):
        output = OutputTool('json')
        output.print_information(self.results_file_path, self.results_store)

        with open(self.results_file_path) as f:
            json_dict = json.load(f, encoding='utf-8')
            # in Python2 strings in json decoded dict are Unicode, which would make the test fail
            assert json_dict == json.loads(json.dumps(self.get_expected_json_output()))