Merge "Return default value for pkg_version if missing"
This commit is contained in:
commit
7594bfab79
@ -428,7 +428,10 @@ def _conf_values_type_convert(conf):
|
||||
|
||||
|
||||
def _get_project_version(project):
|
||||
return pkg_resources.get_distribution(project).version
|
||||
try:
|
||||
return pkg_resources.get_distribution(project).version
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def _uncompress_pkiz(token):
|
||||
|
@ -15,6 +15,7 @@
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import pkg_resources
|
||||
import shutil
|
||||
import stat
|
||||
import tempfile
|
||||
@ -2475,6 +2476,19 @@ class TestAuthPluginUserAgentGeneration(BaseAuthTokenMiddlewareTest):
|
||||
project_with_version = '{0}/{1} '.format(project, project_version)
|
||||
self._assert_user_agent(app, project_with_version, project_version)
|
||||
|
||||
def test_project_not_installed_results_in_unknown_version(self):
|
||||
project = uuid.uuid4().hex
|
||||
|
||||
conf = {'username': self.username,
|
||||
'auth_url': self.auth_url,
|
||||
'project': project}
|
||||
|
||||
v = pkg_resources.get_distribution('keystonemiddleware').version
|
||||
|
||||
app = self.create_simple_middleware(conf=conf, use_global_conf=True)
|
||||
project_with_version = '{0}/{1} '.format(project, 'unknown')
|
||||
self._assert_user_agent(app, project_with_version, v)
|
||||
|
||||
def test_project_in_oslo_configuration(self):
|
||||
project = uuid.uuid4().hex
|
||||
project_version = uuid.uuid4().hex
|
||||
|
Loading…
x
Reference in New Issue
Block a user