Merge "remove null_safe_int from module scope"

This commit is contained in:
Jenkins 2017-06-20 22:54:13 +00:00 committed by Gerrit Code Review
commit a0f0678f32
2 changed files with 5 additions and 13 deletions

View File

@ -391,10 +391,6 @@ def null_safe_str(s):
return str(s) if s else ''
def null_safe_int(s):
return int(s) if s else ''
def null_safe_isotime(s):
if isinstance(s, datetime.datetime):
return utils.strtime(s)
@ -475,7 +471,11 @@ def info_from_instance(context, instance, network_info,
# Status properties
state=instance.vm_state,
state_description=null_safe_str(instance.task_state),
progress=null_safe_int(instance.progress),
# NOTE(gibi): It might seems wrong to default the progress to an empty
# string but this is how legacy work and this code only used by the
# legacy notification so try to keep the compatibility here but also
# keep it contained.
progress=int(instance.progress) if instance.progress else '',
# accessIPs
access_ip_v4=instance.access_ip_v4,

View File

@ -39,14 +39,6 @@ class TestNullSafeUtils(test.NoDBTestCase):
line = 'test'
self.assertEqual(line, base.null_safe_str(line))
def test_null_safe_int(self):
number = None
# TODO(gibi): Fix null_safe_int to return 0 as default instead of empty
# string
self.assertEqual('', base.null_safe_int(number))
number = 10
self.assertEqual(number, base.null_safe_int(number))
class TestSendInstanceUpdateNotification(test.NoDBTestCase):