def test_get_versions(self, _os): _os.listdir.return_value = [ "1.0-SNAPSHOT", "2.0.0", "3.0-SNAPSHOT", "1.1", "1.0", ] repo = LocalRepository("/maven") for input, expected in ( ("foo:bar", [ Artifact("foo:bar:3.0-SNAPSHOT"), Artifact("foo:bar:2.0.0"), Artifact("foo:bar:1.1"), Artifact("foo:bar:1.0"), Artifact("foo:bar:1.0-SNAPSHOT"), ]), ("foo:bar:1.0", [Artifact("foo:bar:1.0")]), ("foo:bar:[1.0]", [Artifact("foo:bar:1.0")]), ("foo:bar:[1.0,2.0)", [ Artifact("foo:bar:1.1"), Artifact("foo:bar:1.0"), ]), ("foo:bar:[2.0,3.0)", [ Artifact("foo:bar:3.0-SNAPSHOT"), Artifact("foo:bar:2.0.0"), ]), ): actual = repo.get_versions(input) assert expected == actual, \ "LocalRepository.get_versions(%s)" % input
def test_get_versions(self, _os): _os.listdir.return_value = ["1.0-SNAPSHOT", "2.0.0", "3.0-SNAPSHOT", "1.1", "1.0", ] repo = LocalRepository("/maven") for input, expected in ( ("foo:bar", [Artifact("foo:bar:3.0-SNAPSHOT"), Artifact("foo:bar:2.0.0"), Artifact("foo:bar:1.1"), Artifact("foo:bar:1.0"), Artifact("foo:bar:1.0-SNAPSHOT"), ]), ("foo:bar:1.0", [Artifact("foo:bar:1.0")]), ("foo:bar:[1.0]", [Artifact("foo:bar:1.0")]), ("foo:bar:[1.0,2.0)", [Artifact("foo:bar:1.1"), Artifact("foo:bar:1.0"), ]), ("foo:bar:[2.0,3.0)", [Artifact("foo:bar:3.0-SNAPSHOT"), Artifact("foo:bar:2.0.0"), ]), ): actual = repo.get_versions(input) assert expected == actual, \ "LocalRepository.get_versions(%s)" % input
def test_open(self): with tempfile.NamedTemporaryFile() as tmp: repo = LocalRepository(os.path.dirname(tmp.name)) tmp.write("the file\n") tmp.flush() with repo.open(tmp.name) as fh: assert "the file\n" == fh.read() self.assertRaises(MissingPathError, repo.open, "/does/not/exist")