Esempio n. 1
0
    def test_get_versions(self, _request):
        res = mock.MagicMock(spec=Struct)
        res.__enter__.return_value = StringIO(SIMPLE_METADATA)
        _request.return_value = res

        repo = HttpRepository("http://foo.com/repo")
        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, "HttpRepository.get_versions(%s)" % input
            # reset res contents
            res.__enter__.return_value.seek(0)
Esempio n. 2
0
    def test_get_versions(self, _request):
        res = mock.MagicMock(spec=Struct)
        res.__enter__.return_value = StringIO(SIMPLE_METADATA)
        _request.return_value = res

        repo = HttpRepository("http://foo.com/repo")
        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, "HttpRepository.get_versions(%s)" % input
            # reset res contents
            res.__enter__.return_value.seek(0)
Esempio n. 3
0
    def test_open(self, _request):
        res = mock.MagicMock(spec=Struct)
        res.__enter__.return_value = StringIO(SIMPLE_METADATA)
        _request.side_effect = [res, requests.exceptions.HTTPError]

        repo = HttpRepository("http://foo.com/repo")
        with repo.open("maven-metadata.xml") as fh:
            assert SIMPLE_METADATA == fh.read()
        self.assertRaises(MissingPathError, repo.open, "some/path")
Esempio n. 4
0
    def test_open(self, _request):
        res = mock.MagicMock(spec=Struct)
        res.__enter__.return_value = StringIO(SIMPLE_METADATA)
        _request.side_effect = [res, requests.exceptions.HTTPError]

        repo = HttpRepository("http://foo.com/repo")
        with repo.open("maven-metadata.xml") as fh:
            assert SIMPLE_METADATA == fh.read()
        self.assertRaises(MissingPathError, repo.open, "some/path")
Esempio n. 5
0
 def test_listdir(self, _request):
     res = mock.MagicMock(spec=Struct)
     res.__enter__.return_value = StringIO(SIMPLE_METADATA)
     _request.side_effect = [res, requests.exceptions.HTTPError]
     expected = ["1.0-SNAPSHOT",
                 "1.0",
                 "3.0-SNAPSHOT",
                 "2.0.0",
                 "1.1",
                 ]
     repo = HttpRepository("http://foo.com/repo")
     actual = repo.listdir("foo/bar")
     assert expected == actual
     self.assertRaises(MissingPathError, repo.listdir, "/baz")
Esempio n. 6
0
 def test_listdir(self, _request):
     res = mock.MagicMock(spec=Struct)
     res.__enter__.return_value = StringIO(SIMPLE_METADATA)
     _request.side_effect = [res, requests.exceptions.HTTPError]
     expected = ["1.0-SNAPSHOT",
                 "1.0",
                 "3.0-SNAPSHOT",
                 "2.0.0",
                 "1.1",
                 ]
     repo = HttpRepository("http://foo.com/repo")
     actual = repo.listdir("foo/bar")
     assert expected == actual
     self.assertRaises(MissingPathError, repo.listdir, "/baz")