예제 #1
0
    def test_find_package(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = self.repository.find_package("nose", "1.3.0-1")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-1.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))

        self.assertEqual(metadata.packages, [])
        self.assertEqual(metadata.python, "2.7")

        self.assertEqual(metadata.available, True)
        self.assertEqual(metadata.store_location,
                         "{0}/".format(path_to_uri(_EGGINST_COMMON_DATA)))

        self.assertEqual(metadata.size, os.path.getsize(path))
        self.assertEqual(metadata.md5, compute_md5(path))

        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-2.egg")

        # When
        metadata = self.repository.find_package("nose", "1.3.0-2")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-2.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-2"))
예제 #2
0
    def test_find_package(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = self.repository.find_package("nose", "1.3.0-1")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-1.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))

        self.assertEqual(metadata.packages, [])
        self.assertEqual(metadata.python, "2.7")

        self.assertEqual(metadata.available, True)
        self.assertEqual(metadata.store_location,
                         "{0}/".format(path_to_uri(_EGGINST_COMMON_DATA)))

        self.assertEqual(metadata.size, os.path.getsize(path))
        self.assertEqual(metadata.md5, compute_md5(path))

        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-2.egg")

        # When
        metadata = self.repository.find_package("nose", "1.3.0-2")

        # Then
        self.assertEqual(metadata.key, "nose-1.3.0-2.egg")

        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-2"))
예제 #3
0
    def test_normalize_php_version(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")
        r_normalized = "10.3.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("0.14.1rc1-1")
        r_normalized = "0.14.1.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("2011n-1")
        r_normalized = "2011.14.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)
예제 #4
0
    def test_has_package(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        available_package = PackageMetadata("nose-1.3.0-1.egg", "nose",
                                            version, [], "2.7")

        version = EnpkgVersion.from_string("1.4.0-1")
        unavailable_package = PackageMetadata("nose-1.4.0-1.egg", "nose",
                                              version, [], "2.7")

        # When/Then
        self.assertTrue(self.repository.has_package(available_package))
        self.assertFalse(self.repository.has_package(unavailable_package))
예제 #5
0
    def test_has_package(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        available_package = PackageMetadata("nose-1.3.0-1.egg", "nose",
                                            version, [], "2.7")

        version = EnpkgVersion.from_string("1.4.0-1")
        unavailable_package = PackageMetadata("nose-1.4.0-1.egg", "nose",
                                              version, [], "2.7")

        # When/Then
        self.assertTrue(self.repository.has_package(available_package))
        self.assertFalse(self.repository.has_package(unavailable_package))
예제 #6
0
    def test_normalize_php_version_constraint(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")
        r_normalized = "10.3.0.0-patch1"

        # When
        normalized = _normalize_php_version(version)

        # Then
        self.assertEqual(normalized, r_normalized)

        # Given
        version = EnpkgVersion.from_string("10.3")
        r_normalized = "10.3.0.0"
예제 #7
0
 def _version_factory(upstream, build):
     if (upstream, build) in cache:
         version = cache[(upstream, build)]
     else:
         version = EnpkgVersion.from_upstream_and_build(upstream, build)
         cache[(upstream, build)] = version
     return version
예제 #8
0
    def test_sorted_insertion(self):
        # Given
        eggs = ["nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
        repository = Repository()

        # When
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RemotePackageMetadata.from_egg(path)
            repository.add_package(package)

        # Then
        self.assertEqual([m.version
                          for m in repository._name_to_packages["nose"]],
                         [EnpkgVersion.from_string("1.2.1-1"),
                          EnpkgVersion.from_string("1.3.0-1")])
예제 #9
0
    def find_package_from_requirement(self, requirement):
        """Search for latest package matching the given requirement.

        Parameters
        ----------
        requirement : Requirement
            The requirement to match for.

        Returns
        -------
        package : RepositoryPackageMetadata
            The corresponding metadata.
        """
        name = requirement.name
        version = requirement.version
        build = requirement.build
        if version is None:
            return self.find_latest_package(name)
        else:
            if build is None:
                upstream = PEP386WorkaroundVersion.from_string(version)
                candidates = [p for p in self.find_packages(name)
                              if p.version.upstream == upstream]
                candidates.sort(key=operator.attrgetter("version"))

                if len(candidates) == 0:
                    msg = "No package found for requirement {0!r}"
                    raise NoSuchPackage(msg.format(requirement))

                return candidates[-1]
            else:
                version = EnpkgVersion.from_upstream_and_build(version, build)
                return self.find_package(name, str(version))
예제 #10
0
    def find_package_from_requirement(self, requirement):
        """Search for latest package matching the given requirement.

        Parameters
        ----------
        requirement : Requirement
            The requirement to match for.

        Returns
        -------
        package : RemotePackageMetadata
            The corresponding metadata.
        """
        name = requirement.name
        version = requirement.version
        build = requirement.build
        if version is None:
            return self.find_latest_package(name)
        else:
            if build is None:
                upstream = PEP386WorkaroundVersion.from_string(version)
                candidates = [p for p in self.find_packages(name)
                              if p.version.upstream == upstream]
                candidates.sort(key=operator.attrgetter("version"))

                if len(candidates) == 0:
                    msg = "No package found for requirement {0!r}"
                    raise NoSuchPackage(msg.format(requirement))

                return candidates[-1]
            else:
                version = EnpkgVersion.from_upstream_and_build(version, build)
                return self.find_package(name, str(version))
예제 #11
0
    def test_iter_packages(self):
        # Given
        eggs = ["nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
        repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        # When
        metadata = list(repository.iter_packages())

        # Then
        self.assertEqual(len(metadata), 2)
        self.assertEqual(set(m.version for m in metadata),
                         set([EnpkgVersion.from_string("1.2.1-1"),
                              EnpkgVersion.from_string("1.3.0-1")]))
예제 #12
0
 def from_json_dict(cls, key, json_dict):
     version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
                                                    json_dict["build"])
     return cls(key, json_dict["name"], version, json_dict["packages"],
                json_dict["python"], json_dict["size"], json_dict["md5"],
                json_dict.get("mtime", 0.0), json_dict.get("product", None),
                json_dict.get("available", True),
                json_dict["store_location"])
예제 #13
0
    def test_find_packages_with_version(self):
        # Given/When
        metadata = list(self.repository.find_packages("nose", "1.3.0-1"))

        # Then
        self.assertEqual(len(metadata), 1)

        self.assertEqual(metadata[0].version,
                         EnpkgVersion.from_string("1.3.0-1"))
예제 #14
0
 def from_json_dict(cls, key, json_dict):
     """
     Create an instance from a key (the egg filename) and metadata passed as
     a dictionary
     """
     version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
                                                    json_dict["build"])
     return cls(key, json_dict["name"], version, json_dict["packages"],
                json_dict["python"])
예제 #15
0
    def test_find_packages_with_version(self):
        # Given/When
        metadata = list(self.repository.find_packages("nose", "1.3.0-1"))

        # Then
        self.assertEqual(len(metadata), 1)

        self.assertEqual(metadata[0].version,
                         EnpkgVersion.from_string("1.3.0-1"))
예제 #16
0
파일: package.py 프로젝트: JoelB/enstaller
 def from_json_dict(cls, key, json_dict):
     """
     Create an instance from a key (the egg filename) and metadata passed as
     a dictionary
     """
     version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
                                                    json_dict["build"])
     return cls(key, json_dict["name"], version, json_dict["packages"],
                json_dict["python"])
예제 #17
0
    def test_from_egg(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = PackageMetadata.from_egg(path)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
예제 #18
0
def dummy_installed_package_factory(name,
                                    version,
                                    build,
                                    key=None,
                                    py_ver=PY_VER,
                                    store_location=""):
    key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
    version = EnpkgVersion.from_upstream_and_build(version, build)
    return InstalledPackageMetadata(key, name.lower(), version, [], py_ver, "",
                                    store_location)
예제 #19
0
    def test_fix_php_version(self):
        # Given
        version = EnpkgVersion.from_string("1.0-1")
        r_fixed_version = "1.0-1"

        # When
        fixed = _fix_php_version(version)

        # Then
        self.assertEqual(fixed, r_fixed_version)
예제 #20
0
    def test_from_egg(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = PackageMetadata.from_egg(path)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
예제 #21
0
    def test_casing(self):
        # Given
        version = EnpkgVersion.from_string("10.3-1")

        # When
        metadata = PackageMetadata("MKL-10.3-1.egg", "mkl", version, [],
                                   "2.7")
        # Then
        self.assertEqual(metadata.name, "mkl")
        self.assertEqual(metadata._egg_name, "MKL")
예제 #22
0
    def test_from_pretty_string(self):
        # Given
        pretty_string = "numpy 1.8.1-1; depends (MKL ~= 10.3)"

        # When
        metadata = PackageMetadata._from_pretty_string(pretty_string)

        # Then
        self.assertEqual(metadata.name, "numpy")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.8.1-1"))
        self.assertEqual(metadata.dependencies, frozenset(("MKL 10.3",)))
예제 #23
0
    def test_iter_packages(self):
        # Given
        eggs = ["nose-1.3.0-1.egg", "nose-1.2.1-1.egg"]
        repository = Repository()
        for egg in eggs:
            path = os.path.join(_EGGINST_COMMON_DATA, egg)
            package = RepositoryPackageMetadata.from_egg(path)
            repository.add_package(package)

        # When
        metadata = list(repository.iter_packages())

        # Then
        self.assertEqual(len(metadata), 2)
        self.assertEqual(
            set(m.version for m in metadata),
            set([
                EnpkgVersion.from_string("1.2.1-1"),
                EnpkgVersion.from_string("1.3.0-1")
            ]))
예제 #24
0
    def test_repr(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        metadata = PackageMetadata("nose-1.3.0-1.egg", "nose", version, [],
                                   "2.7")

        # When
        r = repr(metadata)

        # Then
        self.assertEqual(r, "PackageMetadata('nose-1.3.0-1', key='nose-1.3.0-1.egg')")
예제 #25
0
    def test_repr(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        metadata = PackageMetadata("nose-1.3.0-1.egg", "nose", version, [],
                                   "2.7")

        # When
        r = repr(metadata)

        # Then
        self.assertEqual(
            r, "PackageMetadata('nose-1.3.0-1', key='nose-1.3.0-1.egg')")
예제 #26
0
    def test_no_egg_install(self):
        # Given
        prefix = self.prefix
        package_name = "enstaller"
        r_version = EnpkgVersion.from_upstream_and_build(enstaller.__version__,
                                                         1)

        # When
        version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
예제 #27
0
파일: package.py 프로젝트: JoelB/enstaller
    def from_installed_meta_dict(cls, json_dict, prefix=None):
        prefix = prefix or sys.prefix

        key = json_dict["key"]
        name = json_dict["name"]
        upstream_version = json_dict["version"]
        build = json_dict.get("build", 1)
        version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
        packages = json_dict.get("packages", [])
        python = json_dict.get("python", PY_VER)
        ctime = json_dict.get("ctime", time.ctime(0.0))
        return cls(key, name, version, packages, python, ctime, prefix)
예제 #28
0
 def from_installed_meta_dict(cls, json_dict):
     key = json_dict["key"]
     name = json_dict["name"]
     upstream_version = json_dict["version"]
     build = json_dict.get("build", 1)
     version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
     packages = json_dict.get("packages", [])
     python = json_dict.get("python", PY_VER)
     ctime = json_dict.get("ctime", time.ctime(0.0))
     store_location = json_dict.get("store_location", "")
     return cls(key, name, version, packages, python, ctime,
                store_location)
예제 #29
0
    def test_no_egg_install(self):
        # Given
        prefix = self.prefix
        package_name = "enstaller"
        r_version = EnpkgVersion.from_upstream_and_build(
            enstaller.__version__, 1)

        # When
        version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
예제 #30
0
    def test_from_egg(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")
        repository_info = FSRepositoryInfo(path_to_uri(os.path.dirname(path)))

        # When
        metadata = RemotePackageMetadata.from_egg(path, repository_info)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
        self.assertEqual(metadata.source_url, path_to_uri(path))
예제 #31
0
    def test_from_egg(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = RepositoryPackageMetadata.from_egg(path)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
        self.assertEqual(metadata.store_location,
                         "{0}/".format(path_to_uri(_EGGINST_COMMON_DATA)))
        self.assertEqual(metadata.source_url, path_to_uri(path))
예제 #32
0
def dummy_repository_package_factory(name, version, build, key=None,
                                     py_ver=PY_VER, store_location="",
                                     dependencies=None, mtime=0.0):
    dependencies = dependencies or []
    key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
    fake_size = FAKE_SIZE
    fake_md5 = FAKE_MD5
    fake_mtime = mtime
    version = EnpkgVersion.from_upstream_and_build(version, build)
    return RepositoryPackageMetadata(key, name.lower(), version,
                                     dependencies, py_ver, fake_size,
                                     fake_md5, fake_mtime, "commercial",
                                     True, store_location)
예제 #33
0
    def test_from_egg(self):
        # Given
        path = os.path.join(_EGGINST_COMMON_DATA, "nose-1.3.0-1.egg")

        # When
        metadata = RepositoryPackageMetadata.from_egg(path)

        # Then
        self.assertEqual(metadata.name, "nose")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.3.0-1"))
        self.assertEqual(metadata.store_location,
                         "{0}/".format(path_to_uri(_EGGINST_COMMON_DATA)))
        self.assertEqual(metadata.source_url, path_to_uri(path))
예제 #34
0
    def test_from_pretty_string(self):
        # Given
        pretty_string = "numpy 1.8.1-1; depends (MKL ~= 10.3)"
        repository_info = BroodRepositoryInfo("https://acme.com", "acme/looney")

        # When
        metadata = RepositoryPackageMetadata._from_pretty_string(
            pretty_string, repository_info
        )

        # Then
        self.assertEqual(metadata.name, "numpy")
        self.assertEqual(metadata.version, EnpkgVersion.from_string("1.8.1-1"))
        self.assertEqual(metadata.repository_info, repository_info)
        self.assertEqual(metadata.dependencies, frozenset(("MKL 10.3",)))
예제 #35
0
    def test_repr(self):
        # Given
        version = EnpkgVersion.from_string("1.3.0-1")
        repository_info = BroodRepositoryInfo("http://acme.com", "remote")
        package = RepositoryPackageMetadata.from_package(
            PackageMetadata("nose-1.3.0-1.egg", "nose", version, [], "2.7"),
            repository_info,
        )
        r_repr = ("RepositoryPackageMetadata('nose-1.3.0-1', "
                  "repo=BroodRepository(<http://acme.com>, <remote>)")

        # When
        r = repr(package)

        # Then
        self.assertEqual(r, r_repr)
예제 #36
0
def dummy_repository_package_factory(name,
                                     version,
                                     build,
                                     key=None,
                                     py_ver=PY_VER,
                                     store_location="",
                                     dependencies=None,
                                     mtime=0.0):
    dependencies = dependencies or []
    key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
    fake_size = FAKE_SIZE
    fake_md5 = FAKE_MD5
    fake_mtime = mtime
    version = EnpkgVersion.from_upstream_and_build(version, build)
    return RepositoryPackageMetadata(key, name.lower(), version, dependencies,
                                     py_ver, fake_size, fake_md5, fake_mtime,
                                     "commercial", True, store_location)
예제 #37
0
    def test_sorted_packages_invalid(self):
        # Given
        entries = [
            dummy_installed_package_factory("numpy", "1.6.1", 1),
            dummy_installed_package_factory("numpy", "1.8k", 2),
        ]
        repository = Repository()
        for entry in entries:
            repository.add_package(entry)

        # When
        packages = repository.find_sorted_packages("numpy")

        # Then
        self.assertEqual(len(packages), 2)
        assertCountEqual(
            self, [p.version for p in packages],
            [EnpkgVersion.from_string(v) for v in ("1.6.1-1", "1.8k-2")])
예제 #38
0
    def test_sorted_packages_invalid(self):
        # Given
        entries = [
            dummy_installed_package_factory("numpy", "1.6.1", 1),
            dummy_installed_package_factory("numpy", "1.8k", 2),
        ]
        repository = Repository()
        for entry in entries:
            repository.add_package(entry)

        # When
        packages = repository.find_sorted_packages("numpy")

        # Then
        self.assertEqual(len(packages), 2)
        assertCountEqual(self, [p.version for p in packages],
                         [EnpkgVersion.from_string(v)
                          for v in ("1.6.1-1", "1.8k-2")])
예제 #39
0
파일: main.py 프로젝트: cguwilliams/HmyApp
def _get_enstaller_comparable_version(prefix, package_name):
    runtime_version = \
        EnpkgVersion.from_upstream_and_build(enstaller.__version__, 1)

    egg_info_dir = os.path.join(prefix, EGG_INFO, package_name)
    try:
        # Installed as an egg in sys.prefix
        enstaller_package = \
            InstalledPackageMetadata.from_meta_dir(egg_info_dir)
        if str(enstaller_package.version.upstream) != enstaller.__version__:
            # It is both installed as an egg and from sources/develop mode, the
            # latter takes precedence
            current_comparable_version = runtime_version
        else:
            current_comparable_version = enstaller_package.version
    except EnstallerException:
        # Installed from sources, no build number
        current_comparable_version = runtime_version

    return current_comparable_version
예제 #40
0
파일: main.py 프로젝트: JoelB/enstaller
def _get_enstaller_comparable_version(prefix, package_name):
    runtime_version = \
        EnpkgVersion.from_upstream_and_build(enstaller.__version__, 1)

    egg_info_dir = os.path.join(prefix, EGG_INFO, package_name)
    try:
        # Installed as an egg in sys.prefix
        enstaller_package = \
            InstalledPackageMetadata.from_meta_dir(egg_info_dir)
        if str(enstaller_package.version.upstream) != enstaller.__version__:
            # It is both installed as an egg and from sources/develop mode, the
            # latter takes precedence
            current_comparable_version = runtime_version
        else:
            current_comparable_version = enstaller_package.version
    except EnstallerException:
        # Installed from sources, no build number
        current_comparable_version = runtime_version

    return current_comparable_version
예제 #41
0
    def test_s3index_data(self):
        # Given
        md5 = "c68bb183ae1ab47b6d67ca584957c83c"
        r_s3index_data = {
            "available": True,
            "build": 1,
            "md5": md5,
            "mtime": 0.0,
            "name": "nose",
            "packages": [],
            "product": "free",
            "python": "2.7",
            "size": 1,
            "type": "egg",
            "version": "1.3.0",
        }
        version = EnpkgVersion.from_string("1.3.0-1")
        metadata = RepositoryPackageMetadata("nose-1.3.0-1.egg", "nose",
                                             version, [], "2.7", 1, md5, 0.0,
                                             "free", True, "")

        # When/Then
        self.assertEqual(metadata.s3index_data, r_s3index_data)
예제 #42
0
    def find_package(self, name, version):
        """Search for the first match of a package with the given name and
        version.

        Parameters
        ----------
        name : str
            The package name to look for.
        version : str
            The full version string to look for (e.g. '1.8.0-1').

        Returns
        -------
        package : RemotePackageMetadata
            The corresponding metadata.
        """
        version = EnpkgVersion.from_string(version)
        candidates = self._name_to_packages.get(name, [])
        for candidate in candidates:
            if candidate.version == version:
                return candidate
        raise NoSuchPackage("Package '{0}-{1}' not found".format(name,
                                                                 version))
예제 #43
0
    def find_package(self, name, version):
        """Search for the first match of a package with the given name and
        version.

        Parameters
        ----------
        name : str
            The package name to look for.
        version : str
            The full version string to look for (e.g. '1.8.0-1').

        Returns
        -------
        package : RepositoryPackageMetadata
            The corresponding metadata.
        """
        version = EnpkgVersion.from_string(version)
        candidates = self._name_to_packages.get(name, [])
        for candidate in candidates:
            if candidate.version == version:
                return candidate
        raise NoSuchPackage("Package '{0}-{1}' not found".format(name,
                                                                 version))
예제 #44
0
    def test_egg_install_different_versions(self):
        # ensure that we use the build number from installed metadata if
        # version and enstaller.__version__ are the same

        # Given
        prefix = self.prefix
        package_name = "enstaller"
        version_string = "2.7.6"
        build = 4

        json_dict = {
            "arch": None,
            "build": build,
            "ctime": "Mon Oct 20 15:49:19 2014",
            "hook": False,
            "key": "enstaller-{0}-1.egg".format(version_string),
            "name": "enstaller",
            "osdist": None,
            "packages": [],
            "platform": None,
            "python": "2.7",
            "type": "egg",
            "version": version_string,
        }
        r_version = EnpkgVersion.from_upstream_and_build("4.8.0", 1)

        meta_info_path = meta_info_from_prefix(prefix, package_name)
        ensure_dir(meta_info_path)
        with open(meta_info_path, "wt") as fp:
            json.dump(json_dict, fp)

        # When
        with mock.patch("enstaller.__version__", "4.8.0"):
            version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
예제 #45
0
    def test_egg_install_different_versions(self):
        # ensure that we use the build number from installed metadata if
        # version and enstaller.__version__ are the same

        # Given
        prefix = self.prefix
        package_name = "enstaller"
        version_string = "2.7.6"
        build = 4

        json_dict = {
            "arch": None,
            "build": build,
            "ctime": "Mon Oct 20 15:49:19 2014",
            "hook": False,
            "key": "enstaller-{0}-1.egg".format(version_string),
            "name": "enstaller",
            "osdist": None,
            "packages": [],
            "platform": None,
            "python": "2.7",
            "type": "egg",
            "version": version_string,
        }
        r_version = EnpkgVersion.from_upstream_and_build("4.8.0", 1)

        meta_info_path = meta_info_from_prefix(prefix, package_name)
        ensure_dir(meta_info_path)
        with open(meta_info_path, "wt") as fp:
            json.dump(json_dict, fp)

        # When
        with mock.patch("enstaller.__version__", "4.8.0"):
            version = _get_enstaller_comparable_version(prefix, package_name)

        # Then
        self.assertEqual(version, r_version)
예제 #46
0
    def test_s3index_data(self):
        # Given
        md5 = "c68bb183ae1ab47b6d67ca584957c83c"
        r_s3index_data = {
            "available": True,
            "build": 1,
            "md5": md5,
            "mtime": 0.0,
            "name": "nose",
            "packages": [],
            "product": "free",
            "python": "2.7",
            "size": 1,
            "type": "egg",
            "version": "1.3.0",

        }
        version = EnpkgVersion.from_string("1.3.0-1")
        metadata = RemotePackageMetadata("nose-1.3.0-1.egg", "nose",
                                         version, [], "2.7", 1, md5,
                                         0.0, "free", True, "")

        # When/Then
        self.assertEqual(metadata.s3index_data, r_s3index_data)
예제 #47
0
파일: repack.py 프로젝트: JoelB/enstaller
def _ensure_valid_version(version, build_number):
    full_version = EnpkgVersion.from_upstream_and_build(version,
                                                        build_number)
    if full_version.upstream.is_worked_around:
        raise InvalidVersion(version)