Drop dependency on pytz
... because the current usage can be easily re-implemented using the built-in datetime library. Change-Id: Ic0c7919f0288fd61dd5bfa402c99d7080ffd9083
This commit is contained in:
parent
537e69aeb8
commit
90a82c4b19
|
@ -14,7 +14,6 @@ import datetime
|
|||
from unittest import mock
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import pytz
|
||||
|
||||
from magnum.api import servicegroup as svc_grp
|
||||
from magnum.tests.unit.api import base as api_base
|
||||
|
@ -69,19 +68,23 @@ class TestServiceGroup(api_base.FunctionalTest):
|
|||
self.assertTrue(is_up)
|
||||
|
||||
def test_service_is_up_alive_with_latest_update(self):
|
||||
kwarg = {'created_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC),
|
||||
'updated_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC),
|
||||
'last_seen_up': timeutils.utcnow(True)}
|
||||
kwarg = {
|
||||
'created_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
'updated_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
'last_seen_up': timeutils.utcnow(True)
|
||||
}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
self.assertTrue(is_up)
|
||||
|
||||
def test_service_is_up_down(self):
|
||||
kwarg = {'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC)}
|
||||
kwarg = {
|
||||
'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc)
|
||||
}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
|
@ -89,7 +92,7 @@ class TestServiceGroup(api_base.FunctionalTest):
|
|||
|
||||
def test_service_is_up_down_with_create(self):
|
||||
kwarg = {'created_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC)}
|
||||
tzinfo=datetime.timezone.utc)}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
|
@ -97,29 +100,33 @@ class TestServiceGroup(api_base.FunctionalTest):
|
|||
|
||||
def test_service_is_up_down_with_update(self):
|
||||
kwarg = {'updated_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC)}
|
||||
tzinfo=datetime.timezone.utc)}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
self.assertFalse(is_up)
|
||||
|
||||
def test_service_is_up_down_with_all_three(self):
|
||||
kwarg = {'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC),
|
||||
'created_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC),
|
||||
'updated_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC)}
|
||||
kwarg = {
|
||||
'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
'created_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
'updated_at': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc)
|
||||
}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
self.assertFalse(is_up)
|
||||
|
||||
def test_service_is_up_down_with_old_update(self):
|
||||
kwarg = {'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=pytz.UTC),
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'updated_at': timeutils.utcnow(True)}
|
||||
kwarg = {
|
||||
'last_seen_up': datetime.datetime(1970, 1, 1,
|
||||
tzinfo=datetime.timezone.utc),
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'updated_at': timeutils.utcnow(True)
|
||||
}
|
||||
magnum_object = obj_util.get_test_magnum_service_object(
|
||||
self.context, **kwarg)
|
||||
is_up = self.servicegroup_api.service_is_up(magnum_object)
|
||||
|
|
|
@ -14,8 +14,6 @@ Utils for testing the API service.
|
|||
"""
|
||||
import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from magnum.api.controllers.v1 import cluster as cluster_controller
|
||||
from magnum.api.controllers.v1 import cluster_template as cluster_tmp_ctrl
|
||||
from magnum.api.controllers.v1 import federation as federation_controller
|
||||
|
@ -58,7 +56,7 @@ def quota_post_data(**kw):
|
|||
|
||||
def mservice_get_data(**kw):
|
||||
"""Simulate what the RPC layer will get from DB """
|
||||
faketime = datetime.datetime(2001, 1, 1, tzinfo=pytz.UTC)
|
||||
faketime = datetime.datetime(2001, 1, 1, tzinfo=datetime.timezone.utc)
|
||||
return {
|
||||
'binary': kw.get('binary', 'magnum-conductor'),
|
||||
'host': kw.get('host', 'fake-host'),
|
||||
|
|
|
@ -15,7 +15,6 @@ oslotest>=4.4.1 # Apache-2.0
|
|||
osprofiler>=3.4.0 # Apache-2.0
|
||||
Pygments>=2.7.2 # BSD license
|
||||
python-subunit>=1.4.0 # Apache-2.0/BSD
|
||||
pytz>=2020.4 # MIT
|
||||
requests-mock>=1.2.0 # Apache-2.0
|
||||
testrepository>=0.0.20 # Apache-2.0/BSD
|
||||
stestr>=3.1.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue