Exemplo n.º 1
0
    def test_get_latest_versions_bad_limit(self):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig

        config = GenericArtifactoryClientConfig()
        maven_client = GenericArtifactoryClient(config)

        with pytest.raises(ValueError):
            maven_client.get_latest_versions('com.example.users.service', limit=0)
Exemplo n.º 2
0
    def test_get_latest_versions_release_only_snapshot_results(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig
        from stac.exceptions import NoMatchingVersionsError

        version_dao.get_most_recent_versions.return_value = []

        config = GenericArtifactoryClientConfig()
        config.is_integration = False
        config.http_dao = version_dao
        config.url_generator = url_generator

        maven_client = GenericArtifactoryClient(config)

        with pytest.raises(NoMatchingVersionsError):
            maven_client.get_latest_versions('com.example.users.service')
Exemplo n.º 3
0
    def test_get_latest_versions_release_no_results(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig
        from stac.exceptions import NoMatchingVersionsError

        request = mock.Mock(spec=requests.Request)
        response = mock.Mock(spec=requests.Response)
        response.status_code = 404
        error = requests.HTTPError("Something bad", request=request, response=response)
        version_dao.get_most_recent_versions.side_effect = error

        config = GenericArtifactoryClientConfig()
        config.is_integration = False
        config.http_dao = version_dao
        config.url_generator = url_generator

        maven_client = GenericArtifactoryClient(config)

        with pytest.raises(NoMatchingVersionsError):
            maven_client.get_latest_versions('com.example.users.service')
Exemplo n.º 4
0
    def test_get_latest_versions_release(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig

        version_dao.get_most_recent_versions.return_value = ['1.2.1', '1.2.0', '1.1.1']

        config = GenericArtifactoryClientConfig()
        config.is_integration = False
        config.http_dao = version_dao
        config.url_generator = url_generator

        maven_client = GenericArtifactoryClient(config)
        versions = maven_client.get_latest_versions('com.example.users.service', limit=3)
        expected = [
            '1.2.1',
            '1.2.0',
            '1.1.1'
        ]

        assert expected == versions