示例#1
0
    def testGetVersions(self):
        versions = self._versionDirectory.getVersions()
        versions.sort()

        self.assertEquals([
            Version("2"),
            Version("3.5.6.7"),
            Version("4.8"),
            Version("6.1.2")
        ], versions)
示例#2
0
文件: maven.py 项目: pombredanne/Iris
    def __init__(self,
                 groupId,
                 artifactId=None,
                 version=None,
                 description=None,
                 scope=None):
        assert (groupId is not None)

        self._groupId = groupId
        self._artifactId = artifactId
        self._version = Version(version) if version is not None else None
        self._description = description
        self._scope = scope
示例#3
0
    def testComparisonWithMajor(self):
        laterVersion = Version("5")
        olderVersion = Version("4")

        assert (olderVersion < laterVersion)
示例#4
0
 def testConstructorWithMajorMinorBuildAndRelease(self):
     version = Version("5.6.7.8")
     self.assertEquals(version, "5.6.7.8")
示例#5
0
 def testConstructorWithMajorMinorAndBuild(self):
     version = Version("5.6.7")
     self.assertEquals(version, "5.6.7")
示例#6
0
 def testConstructorWithMajorAndMinor(self):
     version = Version("5.6")
     self.assertEquals(version, "5.6")
示例#7
0
    def testEqualityWithMajorMinorBuildAndRelease(self):
        firstVersion = Version("4.5.6.7")
        secondVersion = Version("4.5.6.7")

        self.assertEquals(firstVersion, secondVersion)
示例#8
0
文件: maven.py 项目: pombredanne/Iris
class MavenArtifact:
    """
    A Maven artifact, identified by some common attributes
    """
    def __init__(self,
                 groupId,
                 artifactId=None,
                 version=None,
                 description=None,
                 scope=None):
        assert (groupId is not None)

        self._groupId = groupId
        self._artifactId = artifactId
        self._version = Version(version) if version is not None else None
        self._description = description
        self._scope = scope

    def getGroupId(self):
        return self._groupId

    def getArtifactId(self):
        return self._artifactId

    def getVersion(self):
        return self._version

    def getDescription(self):
        return self._description

    def getScope(self):
        return self._scope

    def getFileName(self, suffix=None, extension="jar"):
        """
        Returns the basename of the artifact's file, using Maven's conventions.

        In particular, it will be:

            <artifactId>-<version>[-<suffix>][.<extension>]
        """

        assert (self._artifactId is not None)
        assert (self._version is not None)

        return "{0}-{1}{2}{3}".format(
            self._artifactId, self._version.getRawString(),
            "-" + suffix.lstrip("-") if suffix is not None else "",
            "." + extension.lstrip(".") if extension is not None else "")

    def getPath(self, suffix=None, extension="jar", separator=os.sep):
        """
        Returns the full path, relative to the root of a Maven repository,
        of the current artifact, using Maven's conventions.

        In particular, it will be:

            <groupId with "." replaced by <separator>>[<separator><artifactId><separator>[<version><separator><basename obtained via getFileName()>]]
            
        By default, <separator>=os.sep
        """

        assert (self._groupId is not None)

        resultComponents = [self._groupId.replace(".", separator)]

        if self._artifactId is not None:
            resultComponents.append(self._artifactId)

            version = self._version
            if version is not None:
                resultComponents.append(version.getRawString())
                resultComponents.append(self.getFileName(suffix, extension))

        return separator.join(resultComponents)

    def __str__(self):
        """
        An artifact can be shown as a string only if its POM coordinates
        were all provided
        """
        assert (self._artifactId is not None)
        assert (self._version is not None)

        return "{0}:{1}:{2}".format(self._groupId, self._artifactId,
                                    self._version.getRawString())
示例#9
0
    def testComparisonWithRevision(self):
        laterVersion = Version("5.4.8.3")
        olderVersion = Version("5.4.8.2")

        assert (olderVersion < laterVersion)
示例#10
0
 def testCastingToStringWithAlternateZeros(self):
     versionString = "0.2.0.4"
     version = Version(versionString)
     self.assertEquals(versionString, str(version))
示例#11
0
 def testCastingToStringWhenOnlyTheRevisionIsNonZero(self):
     versionString = "0.0.0.4"
     version = Version(versionString)
     self.assertEquals(versionString, str(version))
示例#12
0
 def testRepr(self):
     rawString = "7.6.0"
     version = Version(rawString)
     self.assertEquals(rawString, repr(version))
示例#13
0
 def testConstructorWhenPassingAnotherVersion(self):
     version = Version("6.7.8.9")
     self.assertEquals(version, Version(version))
示例#14
0
    def testGetLatestVersion(self):
        latestVersion = self._versionDirectory.getLatestVersion()

        self.assertEquals(Version("6.1.2"), latestVersion)
示例#15
0
 def testConstructorWithFullStringParameter(self):
     version = Version("1.2.3.4")
     self.assertEquals(1, version.getMajor())
     self.assertEquals(2, version.getMinor())
     self.assertEquals(3, version.getBuild())
     self.assertEquals(4, version.getRevision())
示例#16
0
    def testComparisonWithMinor(self):
        laterVersion = Version("5.4")
        olderVersion = Version("5.3")

        assert (olderVersion < laterVersion)
示例#17
0
    def testComparisonWithBuild(self):
        laterVersion = Version("5.4.8")
        olderVersion = Version("5.4.7")

        assert (olderVersion < laterVersion)
示例#18
0
 def testEqualityOfVersionAndString(self):
     version = Version("1.2.3.4")
     self.assertEquals(version, "1.2.3.4")
示例#19
0
    def testEqualityWithMajor(self):
        firstVersion = Version("4")
        secondVersion = Version("4")

        self.assertEquals(firstVersion, secondVersion)
示例#20
0
 def testEqualityOfVersionAndStringWhenThereAreTrailingZeros(self):
     version = Version("1.2")
     self.assertEquals(version, "1.2")
     self.assertEquals(version, "1.2.0")
     self.assertEquals(version, "1.2.0.0")
示例#21
0
 def testConstructorWithOnlyMajor(self):
     version = Version("5")
     self.assertEquals(version, "5")
示例#22
0
    def testEqualityWithMajorMinorAndBuild(self):
        firstVersion = Version("4.5.6")
        secondVersion = Version("4.5.6")

        self.assertEquals(firstVersion, secondVersion)