Ejemplo n.º 1
0
 def results_store(self):
     rs = ResultsStore()
     rs.set_info_text('Information text', 'some information text')
     rs.set_info_text('Next Information', 'some another information text')
     rs.set_patches_results(self.patches_data)
     rs.set_build_data('old', self.old_rpm_data)
     rs.set_build_data('new', self.new_rpm_data)
     return rs
Ejemplo n.º 2
0
 def setup(self):
     self.results_store = ResultsStore()
     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_store.set_patches_results(self.patches_data)
     self.results_store.set_build_data('old', self.old_rpm_data)
     self.results_store.set_build_data('new', self.new_rpm_data)
 def results_store(self):
     rs = ResultsStore()
     rs.set_info_text('Information text', 'some information text')
     rs.set_info_text('Next Information', 'some another information text')
     rs.set_patches_results(self.patches_data)
     rs.set_build_data('old', self.old_rpm_data)
     rs.set_build_data('new', self.new_rpm_data)
     return rs
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    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')
Ejemplo n.º 6
0
 def setup(self):
     self.results_store = ResultsStore()
     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_store.set_patches_results(self.patches_data)
     self.results_store.set_build_data('old', self.old_rpm_data)
     self.results_store.set_build_data('new', self.new_rpm_data)
Ejemplo n.º 7
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
Ejemplo n.º 8
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()))
Ejemplo n.º 9
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()))
Ejemplo n.º 10
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
Ejemplo n.º 11
0
class TestResultsStore(object):
    """
    tests of ResultsStore class
    """
    old_rpm_data = {'rpm': ['rpm-0.1.0.x86_64.rpm', ' rpm-devel-0.1.0.x86_64.rpm'],
                'srpm': 'rpm-0.1.0.src.rpm',
                'logs': ['logfile1.log', 'logfile2.log']}
    new_rpm_data = {'rpm': ['rpm-0.2.0.x86_64.rpm', ' rpm-devel-0.2.0.x86_64.rpm'],
                'srpm': 'rpm-0.2.0.src.rpm',
                'logs': ['logfile3.log', 'logfile4.log']}
    patches_data = {'deleted': ['del_patch1.patch', 'del_patch2.patch'],
                    'modified': ['mod_patch1.patch', 'mod_patch2.patch']}
    info_data = {'Information text': 'some information text'}
    info_data2 = {'Next Information': 'some another information text'}

    def setup(self):
        self.results_store = ResultsStore()
        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_store.set_patches_results(self.patches_data)
        self.results_store.set_build_data('old', self.old_rpm_data)
        self.results_store.set_build_data('new', self.new_rpm_data)

    def test_base_output_info(self):
        """
        Test Output logger info

        :return: 
        """
        info_results = self.results_store.get_summary_info()
        expect_dict = self.info_data
        expect_dict.update(self.info_data2)
        assert info_results == expect_dict

    def test_base_output_patches(self):
        """
        Test Output logger patches

        :return: 
        """
        patch_results = self.results_store.get_patches()
        expected_patches = self.patches_data
        assert patch_results == expected_patches

    def test_base_output_builds_old(self):
        """
        Test Output logger old builds

        :return: 
        """
        build_results = self.results_store.get_build('old')
        assert build_results == self.old_rpm_data

    def test_base_output_builds_new(self):
        """
        Test Output logger new builds

        :return: 
        """
        build_results = self.results_store.get_build('new')
        assert build_results == self.new_rpm_data
Ejemplo n.º 12
0
class TestResultsStore(object):
    """
    tests of ResultsStore class
    """
    old_rpm_data = {
        'rpm': ['rpm-0.1.0.x86_64.rpm', ' rpm-devel-0.1.0.x86_64.rpm'],
        'srpm': 'rpm-0.1.0.src.rpm',
        'logs': ['logfile1.log', 'logfile2.log']
    }
    new_rpm_data = {
        'rpm': ['rpm-0.2.0.x86_64.rpm', ' rpm-devel-0.2.0.x86_64.rpm'],
        'srpm': 'rpm-0.2.0.src.rpm',
        'logs': ['logfile3.log', 'logfile4.log']
    }
    patches_data = {
        'deleted': ['del_patch1.patch', 'del_patch2.patch'],
        'modified': ['mod_patch1.patch', 'mod_patch2.patch']
    }
    info_data = {'Information text': 'some information text'}
    info_data2 = {'Next Information': 'some another information text'}

    def setup(self):
        self.results_store = ResultsStore()
        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_store.set_patches_results(self.patches_data)
        self.results_store.set_build_data('old', self.old_rpm_data)
        self.results_store.set_build_data('new', self.new_rpm_data)

    def test_base_output_info(self):
        """
        Test Output logger info

        :return: 
        """
        info_results = self.results_store.get_summary_info()
        expect_dict = self.info_data
        expect_dict.update(self.info_data2)
        assert info_results == expect_dict

    def test_base_output_patches(self):
        """
        Test Output logger patches

        :return: 
        """
        patch_results = self.results_store.get_patches()
        expected_patches = self.patches_data
        assert patch_results == expected_patches

    def test_base_output_builds_old(self):
        """
        Test Output logger old builds

        :return: 
        """
        build_results = self.results_store.get_build('old')
        assert build_results == self.old_rpm_data

    def test_base_output_builds_new(self):
        """
        Test Output logger new builds

        :return: 
        """
        build_results = self.results_store.get_build('new')
        assert build_results == self.new_rpm_data