Switch from deprecated oslo_utils.timeutils.strtime
The oslo_utils.timeutils.strtime function is deprecated as of oslo_utils 1.7. DeprecationWarning: Using function/method 'oslo_utils.timeutils.strtime()' is deprecated in version '1.6' and will be removed in a future version: use either datetime.datetime.isoformat() or datetime.datetime.strftime() instead Closes-Bug: 1469867 Change-Id: I97897728703547414a621b6687989cff07e01b3e
This commit is contained in:
parent
97c2c690d8
commit
225832f591
@ -453,7 +453,7 @@ class GeneralAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
|
||||
self.set_middleware(conf=conf)
|
||||
token = b'my_token'
|
||||
some_time_later = timeutils.utcnow() + datetime.timedelta(hours=4)
|
||||
expires = timeutils.strtime(some_time_later)
|
||||
expires = client_utils.strtime(some_time_later)
|
||||
data = ('this_data', expires)
|
||||
token_cache = self.middleware._token_cache
|
||||
token_cache.initialize({})
|
||||
@ -470,7 +470,7 @@ class GeneralAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
|
||||
self.set_middleware(conf=conf)
|
||||
token = b'my_token'
|
||||
some_time_later = timeutils.utcnow() + datetime.timedelta(hours=4)
|
||||
expires = timeutils.strtime(some_time_later)
|
||||
expires = client_utils.strtime(some_time_later)
|
||||
data = ('this_data', expires)
|
||||
token_cache = self.middleware._token_cache
|
||||
token_cache.initialize({})
|
||||
@ -486,7 +486,7 @@ class GeneralAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
|
||||
self.set_middleware(conf=conf)
|
||||
token = 'my_token'
|
||||
some_time_later = timeutils.utcnow() + datetime.timedelta(hours=4)
|
||||
expires = timeutils.strtime(some_time_later)
|
||||
expires = client_utils.strtime(some_time_later)
|
||||
data = ('this_data', expires)
|
||||
token_cache = self.middleware._token_cache
|
||||
token_cache.initialize({})
|
||||
@ -1821,7 +1821,7 @@ class TokenExpirationTest(BaseAuthTokenMiddlewareTest):
|
||||
data = 'this_data'
|
||||
self.set_middleware()
|
||||
self.middleware._token_cache.initialize({})
|
||||
some_time_later = timeutils.strtime(at=(self.now + self.delta))
|
||||
some_time_later = client_utils.strtime(at=(self.now + self.delta))
|
||||
expires = some_time_later
|
||||
self.middleware._token_cache.store(token, data, expires)
|
||||
self.assertEqual(self.middleware._token_cache._cache_get(token), data)
|
||||
@ -1849,7 +1849,7 @@ class TokenExpirationTest(BaseAuthTokenMiddlewareTest):
|
||||
data = 'this_data'
|
||||
self.set_middleware()
|
||||
self.middleware._token_cache.initialize({})
|
||||
some_time_earlier = timeutils.strtime(at=(self.now - self.delta))
|
||||
some_time_earlier = client_utils.strtime(at=(self.now - self.delta))
|
||||
expires = some_time_earlier
|
||||
self.middleware._token_cache.store(token, data, expires)
|
||||
self.assertThat(lambda: self.middleware._token_cache._cache_get(token),
|
||||
@ -1862,7 +1862,7 @@ class TokenExpirationTest(BaseAuthTokenMiddlewareTest):
|
||||
self.middleware._token_cache.initialize({})
|
||||
timezone_offset = datetime.timedelta(hours=2)
|
||||
some_time_later = self.now - timezone_offset + self.delta
|
||||
expires = timeutils.strtime(some_time_later) + '-02:00'
|
||||
expires = client_utils.strtime(some_time_later) + '-02:00'
|
||||
self.middleware._token_cache.store(token, data, expires)
|
||||
self.assertEqual(self.middleware._token_cache._cache_get(token), data)
|
||||
|
||||
@ -1873,7 +1873,7 @@ class TokenExpirationTest(BaseAuthTokenMiddlewareTest):
|
||||
self.middleware._token_cache.initialize({})
|
||||
timezone_offset = datetime.timedelta(hours=2)
|
||||
some_time_earlier = self.now - timezone_offset - self.delta
|
||||
expires = timeutils.strtime(some_time_earlier) + '-02:00'
|
||||
expires = client_utils.strtime(some_time_earlier) + '-02:00'
|
||||
self.middleware._token_cache.store(token, data, expires)
|
||||
self.assertThat(lambda: self.middleware._token_cache._cache_get(token),
|
||||
matchers.raises(auth_token.InvalidUserToken))
|
||||
|
@ -14,7 +14,6 @@
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from testtools import matchers
|
||||
@ -22,6 +21,7 @@ from testtools import matchers
|
||||
from keystoneclient import session
|
||||
from keystoneclient.tests.unit.v3 import client_fixtures
|
||||
from keystoneclient.tests.unit.v3 import utils
|
||||
from keystoneclient import utils as client_utils
|
||||
from keystoneclient.v3.contrib.oauth1 import access_tokens
|
||||
from keystoneclient.v3.contrib.oauth1 import auth
|
||||
from keystoneclient.v3.contrib.oauth1 import consumers
|
||||
@ -90,7 +90,7 @@ class TokenTests(BaseTest):
|
||||
|
||||
def _new_oauth_token_with_expires_at(self):
|
||||
key, secret, token = self._new_oauth_token()
|
||||
expires_at = timeutils.strtime()
|
||||
expires_at = client_utils.strtime()
|
||||
params = {'oauth_token': key,
|
||||
'oauth_token_secret': secret,
|
||||
'oauth_expires_at': expires_at}
|
||||
|
@ -366,3 +366,8 @@ def isotime(at=None, subsecond=False):
|
||||
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
|
||||
st += ('Z' if tz == 'UTC' else tz)
|
||||
return st
|
||||
|
||||
|
||||
def strtime(at=None):
|
||||
at = at or timeutils.utcnow()
|
||||
return at.strftime(timeutils.PERFECT_TIME_FORMAT)
|
||||
|
Loading…
Reference in New Issue
Block a user