Esempio n. 1
0
    def test_from_yaml_one_trace(self):
        """compare_replay.from_yaml: compare using a YAML with just one expectation for the used device"""

        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.from_yaml('one-trace.yml') is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_called_once()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_called_once()
        dumped_image_path = '{}-99.png'.format(self.trace_path)
        root, ext = path.splitext(dumped_image_path)
        assert not self.tmpdir.join(self.results_partial_path,
                                    dumped_image_path).check()
        assert not self.tmpdir.join(
            self.results_partial_path, '{}-{}{}'.format(
                root, self.exp_checksum, ext)).check()
        s = f.getvalue()
        assert s == ('[check_image]\n'
                     '    actual: ' + self.exp_checksum + '\n'
                     '  expected: ' + self.exp_checksum + '\n'
                     '[check_image] Images match for:\n'
                     '  ' + self.trace_path + '\n'
                     '\n')
Esempio n. 2
0
def _from_yaml(args):
    options.OPTIONS.device_name = args.device_name
    options.OPTIONS.keep_image = args.keep_image
    options.OPTIONS.download['force'] = args.force_download
    options.OPTIONS.db_path = args.db_path
    options.OPTIONS.results_path = args.output

    return compare_replay.from_yaml(args.yaml_file)
Esempio n. 3
0
    def test_from_yaml_no_device(self):
        """compare_replay.from_yaml: compare using a YAML without expectations for the used device"""

        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.from_yaml('no-device.yml') is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_called_once()
        s = f.getvalue()
        assert s == ''
Esempio n. 4
0
    def test_from_yaml_empty(self):
        """compare_replay.from_yaml: compare using an empty YAML file"""

        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.from_yaml('empty.yml') is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_called_once()
        s = f.getvalue()
        assert s == ''
Esempio n. 5
0
    def test_from_yaml_two_traces(self):
        """compare_replay.from_yaml: compare using a YAML with more than one expectation for the used device"""

        second_trace_path = 'pathfinder/demo.trace'
        second_exp_checksum = 'e624d76c70cc3c532f4f54439e13659a'
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.from_yaml('two-traces.yml') is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_called_once()
        assert self.m_ensure_file.call_count == 2
        assert self.m_backends_dump.call_count == 2
        assert self.m_hexdigest_from_image.call_count == 2
        dumped_image_path = '{}-78.png'.format(second_trace_path)
        root, ext = path.splitext(dumped_image_path)
        assert not self.tmpdir.join(self.results_partial_path,
                                    dumped_image_path).check()
        assert not self.tmpdir.join(
            self.results_partial_path, '{}-{}{}'.format(
                root, second_exp_checksum, ext)).check()
        dumped_image_path = '{}-99.png'.format(self.trace_path)
        root, ext = path.splitext(dumped_image_path)
        assert not self.tmpdir.join(self.results_partial_path,
                                    dumped_image_path).check()
        assert not self.tmpdir.join(
            self.results_partial_path, '{}-{}{}'.format(
                root, self.exp_checksum, ext)).check()
        s = f.getvalue()
        assert s == ('[check_image]\n'
                     '    actual: ' + second_exp_checksum + '\n'
                     '  expected: ' + second_exp_checksum + '\n'
                     '[check_image] Images match for:\n'
                     '  ' + second_trace_path + '\n'
                     '\n'
                     '[check_image]\n'
                     '    actual: ' + self.exp_checksum + '\n'
                     '  expected: ' + self.exp_checksum + '\n'
                     '[check_image] Images match for:\n'
                     '  ' + self.trace_path + '\n'
                     '\n')