Beispiel #1
0
def _execute(module_id, dist_files_tuple_array, freeze_file, module_file,
             force_dependency_rebuild, force_clean, expected_module_properties,
             expected_artifacts, expected_dependencies):
    #tuple pattern is: (command, python_version, dist_file)

    checksum_dependency_helper = ChecksumDependencyHelper(
        determine_file_path_fn=helper.determine_file_path,
        determine_checksums_from_file_path_fn=helper.
        determine_checksums_from_file_path)

    build_info_module_generator = BuildInfoModuleGenerator(
        determine_dependency_checksums_fn=checksum_dependency_helper)

    ########################################
    #Invoke functionality being tested
    build_info_module_generator.update(
        module_id=module_id,
        module_properties=helper.module_properties,
        freeze_file=freeze_file,
        dist_files=dist_files_tuple_array,
        module_file=module_file,
        force_dependency_rebuild=force_dependency_rebuild,
        force_clean=force_clean)

    ########################################
    #validate behavior
    module = _read_module_file(module_file)
    eq_(module.id, module_id)
    eq_(module.artifacts, expected_artifacts)
    eq_(module.dependencies, expected_dependencies)
    eq_(module.properties, expected_module_properties)
Beispiel #2
0
def temp_fn_02():
    module_output_file_name = _create_temp_file_name()
    exception_caught = False
    try:
        checksum_dependency_helper = ChecksumDependencyHelper(
            determine_file_path_fn=helper.determine_file_path,
            determine_checksums_from_file_path_fn=helper.
            determine_checksums_from_file_path_throw_exception)

        build_info_module_generator = BuildInfoModuleGenerator(
            determine_dependency_checksums_fn=checksum_dependency_helper)

        ########################################
        #Invoke functionality being tested
        build_info_module_generator.update(
            module_id=helper.module_id,
            module_properties=helper.module_properties,
            freeze_file=helper.full_requirements_file,
            dist_files=[
                ('sdist', None, helper.sdist_file),
                #        ('bdist', None, bdist_file),
                ('bdist_egg', None, helper.egg_file)
            ],
            module_file=module_output_file_name,
            force_dependency_rebuild=False,
            force_clean=False)
    except HTTPError:
        exception_caught = True
        #Make sure no trash module file is left behind
        assert not os.path.exists(module_output_file_name)

    assert exception_caught, "Expect HTTPError to be encountered"
def temp_fn_02():
    module_output_file_name = _create_temp_file_name()
    exception_caught = False
    try:
        checksum_dependency_helper = ChecksumDependencyHelper(
            determine_file_path_fn=helper.determine_file_path,
            determine_checksums_from_file_path_fn=
            helper.determine_checksums_from_file_path_throw_exception)

        build_info_module_generator = BuildInfoModuleGenerator(
            determine_dependency_checksums_fn=checksum_dependency_helper)

        ########################################
        #Invoke functionality being tested
        build_info_module_generator.update(
            module_id=helper.module_id,
            module_properties=helper.module_properties,
            freeze_file=helper.full_requirements_file,
            dist_files=[
                ('sdist', None, helper.sdist_file),
                #        ('bdist', None, bdist_file),
                ('bdist_egg', None, helper.egg_file)],
            module_file=module_output_file_name,
            force_dependency_rebuild=False,
            force_clean=False)
    except HTTPError:
        exception_caught = True
        #Make sure no trash module file is left behind
        assert not os.path.exists(module_output_file_name)

    assert exception_caught, "Expect HTTPError to be encountered"
    def run(self):
        module_id = self._determine_module_id()
        self.announce(
            'Creating module_info file for module: {}'.format(module_id),
            level=log.INFO
        )

        # This command is never used interactively, so it doesn't make
        # sense to add support for passing in repo details like the
        # artifactory_upload command does. If that changes in the future
        # this command can always be enhanced at that time. The work
        # involved to add the options isn't so much in the code changes
        # to this command as in the test coverage that would need to be
        # written. It would also probably require refactoring the
        # commands to share a common base class. All this currently
        # falls under YAGNI (You're Not Going To Need It).

        verify_cert = not self.no_cert_verify
        repo_details = read_options()

        pip_package_path_finder = PipPackagePathFinder()

        def determine_checksums(file_path):
            return artifactory_rest.determine_checksums(
                username=repo_details.username,
                password=repo_details.password,
                repo_pull_id=repo_details.repo_pull_id,
                repo_base_url=repo_details.repo_base_url,
                file_path=file_path,
                verify_cert=verify_cert)

        checksum_dependency_helper = ChecksumDependencyHelper(
            determine_file_path_fn=pip_package_path_finder.determine_file_path,
            determine_checksums_from_file_path_fn=determine_checksums)

        build_info_module_generator = BuildInfoModuleGenerator(
            determine_dependency_checksums_fn=checksum_dependency_helper)

        requirements_file = compute_requirements_filename_full_path(
            artifact_id=module_id.artifact_id,
            version=module_id.version)

        module_info_file = compute_module_info_filename_full_path(
            artifact_id=module_id.artifact_id,
            version=module_id.version)

        build_info_module_generator.update(
            module_id=module_id,
            module_properties={},
            freeze_file=requirements_file,
            dist_files=self.distribution.dist_files,
            module_file=module_info_file,
            force_dependency_rebuild=bool(self.force_dependency_rebuild),
            force_clean=bool(self.force_clean))

        self.announce(
            'Module info file created at: {}'.format(module_info_file),
            level=log.INFO)
Beispiel #5
0
    def run(self):
        module_id = self._determine_module_id()
        self.announce(
            'Creating module_info file for module: {}'.format(module_id),
            level=log.INFO)

        # This command is never used interactively, so it doesn't make
        # sense to add support for passing in repo details like the
        # artifactory_upload command does. If that changes in the future
        # this command can always be enhanced at that time. The work
        # involved to add the options isn't so much in the code changes
        # to this command as in the test coverage that would need to be
        # written. It would also probably require refactoring the
        # commands to share a common base class. All this currently
        # falls under YAGNI (You're Not Going To Need It).

        verify_cert = not self.no_cert_verify
        repo_details = read_options()

        pip_package_path_finder = PipPackagePathFinder()

        def determine_checksums(file_path):
            return artifactory_rest.determine_checksums(
                username=repo_details.username,
                password=repo_details.password,
                repo_pull_id=repo_details.repo_pull_id,
                repo_base_url=repo_details.repo_base_url,
                file_path=file_path,
                verify_cert=verify_cert)

        checksum_dependency_helper = ChecksumDependencyHelper(
            determine_file_path_fn=pip_package_path_finder.determine_file_path,
            determine_checksums_from_file_path_fn=determine_checksums)

        build_info_module_generator = BuildInfoModuleGenerator(
            determine_dependency_checksums_fn=checksum_dependency_helper)

        requirements_file = compute_requirements_filename_full_path(
            artifact_id=module_id.artifact_id, version=module_id.version)

        module_info_file = compute_module_info_filename_full_path(
            artifact_id=module_id.artifact_id, version=module_id.version)

        build_info_module_generator.update(
            module_id=module_id,
            module_properties={},
            freeze_file=requirements_file,
            dist_files=self.distribution.dist_files,
            module_file=module_info_file,
            force_dependency_rebuild=bool(self.force_dependency_rebuild),
            force_clean=bool(self.force_clean))

        self.announce(
            'Module info file created at: {}'.format(module_info_file),
            level=log.INFO)
def test_case_sensitive_dependencies():
    """
    Verify that artifact IDs of dependencies match the real project
    name, not the case-insensitive key.
    """

    class MockModuleBuilder(object):
        def __init__(self):
            self.__module_names = []

        def ensure_dependencies_defined(self):
            pass

        # noinspection PyShadowingBuiltins
        def add_dependency(self, type, id, sha1, md5):
            self.__module_names.append(id.artifact_id)

        def compare_modules(self, freeze_file):
            with open(freeze_file) as f:
                modules = f.read().splitlines()

            expected_set = frozenset([m.split('==')[0] for m in modules])
            actual_set = frozenset(self.__module_names)

            assert actual_set == expected_set, (
                '\nActual module names:\n    {}'
                '\nExpected module names:\n    {}'.format(
                    '\n    '.join(pprint.pformat(actual_set).splitlines()),
                    '\n    '.join(pprint.pformat(expected_set).splitlines())))

            eq_(actual_set, expected_set)

    generator = BuildInfoModuleGenerator(
        determine_dependency_checksums_fn=
        lambda artifact_id, version: (None, None))

    freeze_file = os.path.join(os.path.dirname(
        os.path.abspath(__file__)), "case-sensitive-requirements.txt")

    mock_module_builder = MockModuleBuilder()
    generator._reset_dependencies(freeze_file, mock_module_builder)
    mock_module_builder.compare_modules(freeze_file)
Beispiel #7
0
def test_case_sensitive_dependencies():
    """
    Verify that artifact IDs of dependencies match the real project
    name, not the case-insensitive key.
    """
    class MockModuleBuilder(object):
        def __init__(self):
            self.__module_names = []

        def ensure_dependencies_defined(self):
            pass

        # noinspection PyShadowingBuiltins
        def add_dependency(self, type, id, sha1, md5):
            self.__module_names.append(id.artifact_id)

        def compare_modules(self, freeze_file):
            with open(freeze_file) as f:
                modules = f.read().splitlines()

            expected_set = frozenset([m.split('==')[0] for m in modules])
            actual_set = frozenset(self.__module_names)

            assert actual_set == expected_set, (
                '\nActual module names:\n    {}'
                '\nExpected module names:\n    {}'.format(
                    '\n    '.join(pprint.pformat(actual_set).splitlines()),
                    '\n    '.join(pprint.pformat(expected_set).splitlines())))

            eq_(actual_set, expected_set)

    generator = BuildInfoModuleGenerator(
        determine_dependency_checksums_fn=lambda artifact_id, version:
        (None, None))

    freeze_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               "case-sensitive-requirements.txt")

    mock_module_builder = MockModuleBuilder()
    generator._reset_dependencies(freeze_file, mock_module_builder)
    mock_module_builder.compare_modules(freeze_file)
def _execute(
        module_id,
        dist_files_tuple_array,
        freeze_file,
        module_file,
        force_dependency_rebuild,
        force_clean,
        expected_module_properties,
        expected_artifacts,
        expected_dependencies):
    #tuple pattern is: (command, python_version, dist_file)

    checksum_dependency_helper = ChecksumDependencyHelper(
        determine_file_path_fn=helper.determine_file_path,
        determine_checksums_from_file_path_fn=
        helper.determine_checksums_from_file_path)

    build_info_module_generator = BuildInfoModuleGenerator(
        determine_dependency_checksums_fn=checksum_dependency_helper)

    ########################################
    #Invoke functionality being tested
    build_info_module_generator.update(
        module_id=module_id,
        module_properties=helper.module_properties,
        freeze_file=freeze_file,
        dist_files=dist_files_tuple_array,
        module_file=module_file,
        force_dependency_rebuild=force_dependency_rebuild,
        force_clean=force_clean)

    ########################################
    #validate behavior
    module = _read_module_file(module_file)
    eq_(module.id, module_id)
    eq_(module.artifacts, expected_artifacts)
    eq_(module.dependencies, expected_dependencies)
    eq_(module.properties, expected_module_properties)