Replace oslo_utils.timeutils.isotime

'oslo_utils.timeutils.isotime()' is deprecated in version '1.6' and
will be removed in a future version: use datetime.isoformat() instead.

Change-Id: I7ac6508510bc0fa131368c27dd8fdcababc37d0b
Closes-Bug: #1514331
This commit is contained in:
huoliang 2016-11-07 15:29:29 +08:00
parent fc32a8b620
commit 1001243d85
4 changed files with 24 additions and 20 deletions

View File

@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from datetime import datetime
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import timeutils
import six
from murano.common import uuidutils
@ -50,7 +50,7 @@ class StatusReporter(object):
'details': details,
'level': level,
'environment_id': self._environment_id,
'timestamp': timeutils.isotime(subsecond=True)
'timestamp': datetime.utcnow().isoformat()
}
self._notifier.info({}, 'murano.report_notification', body)

View File

@ -14,6 +14,7 @@
# limitations under the License.
import cgi
from datetime import datetime
import imghdr
import os
import tempfile
@ -1193,8 +1194,8 @@ This is a fake zip archive
expected = {
'name': 'new_category',
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1],
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7],
'package_count': 0,
}
@ -1217,8 +1218,8 @@ This is a fake zip archive
expected = {
'name': 'new_category',
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1],
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7],
'package_count': 0,
'packages': []
}

View File

@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from datetime import datetime
import mock
from oslo_config import fixture as config_fixture
@ -65,8 +66,8 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
'name': 'mytemp',
'description_text': 'description',
'version': 0,
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1]}
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7]}
body = {'name': 'mytemp', 'description_text': 'description'}
req = self._post('/templates', jsonutils.dump_as_bytes(body))
@ -412,8 +413,8 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
result = req.get_response(self.api)
self.assertEqual(200, result.status_code)
expected['created'] = timeutils.isotime(expected['created'])[:-1]
expected['updated'] = timeutils.isotime(expected['updated'])[:-1]
expected['created'] = datetime.isoformat(expected['created'])[:-7]
expected['updated'] = datetime.isoformat(expected['updated'])[:-7]
self.assertEqual(expected, jsonutils.loads(result.body))
@ -506,8 +507,8 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
'name': 'env_template_name',
'description_text': '',
'version': 0,
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1]}
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7]}
services = [
{

View File

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from datetime import datetime
from oslo_config import fixture as config_fixture
from oslo_serialization import jsonutils
from oslo_utils import timeutils
@ -123,8 +125,8 @@ class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
'name': 'my_env',
'description_text': 'description',
'version': 0,
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1],
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7],
}
body = {'name': 'my_env', 'description_text': 'description'}
@ -314,8 +316,8 @@ class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
result = req.get_response(self.api)
self.assertEqual(200, result.status_code)
expected['created'] = timeutils.isotime(expected['created'])[:-1]
expected['updated'] = timeutils.isotime(expected['updated'])[:-1]
expected['created'] = datetime.isoformat(expected['created'])[:-7]
expected['updated'] = datetime.isoformat(expected['updated'])[:-7]
expected['acquired_by'] = None
self.assertEqual(expected, jsonutils.loads(result.body))
@ -439,8 +441,8 @@ class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
'name': 'my-env',
'version': 0,
'description_text': '',
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1],
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7],
'acquired_by': None,
'services': [],
'status': 'ready',
@ -486,8 +488,8 @@ class TestEnvironmentApi(tb.ControllerTest, tb.MuranoApiTestCase):
'name': 'my-env',
'version': 0,
'description_text': '',
'created': timeutils.isotime(fake_now)[:-1],
'updated': timeutils.isotime(fake_now)[:-1],
'created': datetime.isoformat(fake_now)[:-7],
'updated': datetime.isoformat(fake_now)[:-7],
'acquired_by': sess_id,
'services': [],
'status': states.EnvironmentStatus.DEPLOYING,