예제 #1
0
def test_parse_path():
    pathbuilder = __get_pathbuilder()
    pathbuilder.create()
    pathbuilder2 = output.create_from_path(dirpath=pathbuilder.path)
    __rmbuild_and_validate(pathbuilder)
    assert pathbuilder2, "Could not initialize PathBuilder object with dirpath"
    assert pathbuilder.path == pathbuilder2.path, "The paths don't match!"
    assert pathbuilder == pathbuilder2, "PathBuilder equals did not match!"
예제 #2
0
def test_parse_path():
    pathbuilder = __get_pathbuilder()
    pathbuilder.create()
    pathbuilder2 = output.create_from_path(dirpath=pathbuilder.path)
    __rmbuild_and_validate(pathbuilder)
    assert pathbuilder2, "Could not initialize PathBuilder object with dirpath"
    assert pathbuilder.path == pathbuilder2.path, "The paths don't match!"
    assert pathbuilder == pathbuilder2, "PathBuilder equals did not match!"
예제 #3
0
파일: main.py 프로젝트: GelLiNN/tagcompare
    def compare_builds(self, build, reference='golden'):
        """
        Compares a build against a reference build,
        (by default named 'golden' build)
        :param buildname:
        :param golden:
        :return:
        """
        compare_build = build + "_vs_" + reference
        self.logger.info('Starting compare build: %s', compare_build)

        # Compare all the tag images in the build path against the golden set
        build_paths = output.get_all_paths(
            buildname=build, basedir=OUTPUT_BASEDIR)
        compare_errors = {}

        for bp in build_paths:
            build_pb = output.create_from_path(bp, basepath=OUTPUT_BASEDIR)

            # The reference build is included at the root level of tagtester
            ref_pb = build_pb.clone(
                build=reference, basepath=os.path.dirname(__file__))
            assert os.path.exists(
                ref_pb.buildpath), 'Reference build not found!'

            # We can compare iff both paths exists
            build_image = build_pb.tagimage
            ref_image = ref_pb.tagimage
            if not os.path.exists(build_image):
                self.logger.warn(
                    'SKIPPING compare: path does not exist at {}'.format(
                        build_pb.path))
                continue
            if not os.path.exists(ref_image):
                self.logger.warn(
                    'SKIPPING compare: path does not exist at {}'.format(
                        ref_pb.path))
                # TODO: In this case we want to have the option of making new
                # ref
                continue

            result = image.compare(build_pb.tagimage, ref_pb.tagimage)
            self.logger.debug('Result for %s: %s', compare_build, result)
            if result > settings.ImageErrorLevel.SLIGHT:
                compare_errors[build_image] = result
                self.logger.warn('Invalid compare result for %s', build_image)

        self.logger.info(
            'Finished compare build %s for %s images!  Found %s errors:\n%s',
            compare_build, len(build_paths),
            len(compare_errors), compare_errors)
예제 #4
0
def test_output_create_invalid():
    with pytest.raises(TypeError):
        # Must specify build
        output.create(config="invalidtest")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath="invalid/path")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath=33)

    with pytest.raises(ValueError):
        # Valid path but not enough parts
        output.create_from_path(dirpath="/tmp/")

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=["too", "few", "parts"])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[1, 2, 3, 4, 5], basepath="")
예제 #5
0
def test_output_create_invalid():
    with pytest.raises(TypeError):
        # Must specify build
        output.create(config="invalidtest")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath="invalid/path")

    with pytest.raises(ValueError):
        output.create_from_path(dirpath=33)

    with pytest.raises(ValueError):
        # Valid path but not enough parts
        output.create_from_path(dirpath="/tmp/")

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=["too", "few", "parts"])

    with pytest.raises(ValueError):
        output.PathBuilder(parts=[1, 2, 3, 4, 5], basepath="")