예제 #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)
예제 #2
0
    def test_get_latest_version_release(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig

        version_dao.get_most_recent_release.return_value = '4.13.4'

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

        maven_client = GenericArtifactoryClient(config)
        version = maven_client.get_latest_version('com.example.users.service')
        assert '4.13.4' == version
예제 #3
0
    def test_get_latest_version_snapshot(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig

        version_dao.get_most_recent_versions.return_value = ['1.3.0-SNAPSHOT']

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

        maven_client = GenericArtifactoryClient(config)
        version = maven_client.get_latest_version('com.example.users.service')
        assert '1.3.0-SNAPSHOT' == version
예제 #4
0
    def test_get_latest_version_snapshot_only_release_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 = True
        config.http_dao = version_dao
        config.url_generator = url_generator

        maven_client = GenericArtifactoryClient(config)

        with pytest.raises(NoMatchingVersionsError):
            maven_client.get_latest_version('com.example.users.service')
예제 #5
0
    def test_get_version_url(self, version_dao, url_generator):
        from stac.client import GenericArtifactoryClient, GenericArtifactoryClientConfig

        url_generator.get_url.return_value = ('https://www.example.com/artifactory/libs-release/'
                                              'com/example/services/login/3.9.1/login-3.9.1.jar')

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

        client = GenericArtifactoryClient(config)
        url = client.get_version_url('com.example.services.login', 'jar', '3.9.1')
        assert ('https://www.example.com/artifactory/libs-release/'
                'com/example/services/login/3.9.1/login-3.9.1.jar') == url
예제 #6
0
    def test_get_latest_version_snapshot_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 = True
        config.http_dao = version_dao
        config.url_generator = url_generator

        maven_client = GenericArtifactoryClient(config)

        with pytest.raises(NoMatchingVersionsError):
            maven_client.get_latest_version('com.example.users.service')
예제 #7
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