Drop direct test dependency on iso8601

The current usages can be replaced by the built-in datetime module,
or the utility method from oslo.utils.

Change-Id: I5e13fd132ece859e7b02a76ce1a0435df6e0359e
This commit is contained in:
Takashi Kajinami
2025-03-01 00:55:40 +09:00
parent 9d930fb7e3
commit 9d8f8a13a4
4 changed files with 12 additions and 14 deletions

View File

@@ -17,9 +17,9 @@
from unittest import mock
import ddt
import iso8601
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import timeutils
import webob
from manila.api import extensions
@@ -62,7 +62,7 @@ class ExtensionControllerTest(ExtensionTestCase):
# Ensure all the timestamps are valid according to iso8601
for ext in data['extensions']:
iso8601.parse_date(ext['updated'])
timeutils.parse_isotime(ext['updated'])
# Make sure that at least Fox in Sox is correct.
(fox_ext, ) = [

View File

@@ -11,7 +11,6 @@
# under the License.
import datetime
import iso8601
from manila.message import message_field
from manila.message import message_levels
@@ -31,11 +30,11 @@ def stub_message(id, **kwargs):
'resource_type': message_field.Resource.SHARE,
'resource_id': FAKE_UUID,
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.UTC),
tzinfo=datetime.timezone.utc),
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.UTC),
tzinfo=datetime.timezone.utc),
'expires_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.UTC),
tzinfo=datetime.timezone.utc),
'detail_id': message_field.Detail.NO_VALID_HOST[0],
}
@@ -58,9 +57,9 @@ def stub_lock(id, **kwargs):
'lock_context': 'user',
'lock_reason': 'for the tests',
'updated_at': datetime.datetime(2023, 8, 10, 20, 4, 39,
tzinfo=iso8601.UTC),
tzinfo=datetime.timezone.utc),
'created_at': datetime.datetime(2023, 1, 10, 15, 3, 1,
tzinfo=iso8601.UTC),
tzinfo=datetime.timezone.utc),
}
lock.update(kwargs)

View File

@@ -13,7 +13,6 @@
from unittest import mock
import datetime
import iso8601
from oslo_config import cfg
import webob
@@ -188,8 +187,8 @@ class MessageApiTest(test.TestCase):
def test_index_with_created_since_and_created_before(self):
msg = stubs.stub_message(
fakes.get_fake_uuid(),
created_at=datetime.datetime(1900, 2, 1, 1, 1, 1,
tzinfo=iso8601.UTC))
created_at=datetime.datetime(
1900, 2, 1, 1, 1, 1, tzinfo=datetime.timezone.utc))
self.mock_object(message_api.API, 'get_all', mock.Mock(
return_value=[msg]))
req = fakes.HTTPRequest.blank(
@@ -203,8 +202,9 @@ class MessageApiTest(test.TestCase):
ex2 = self._expected_message_from_controller(
msg['id'],
created_at=datetime.datetime(1900, 2, 1, 1, 1, 1,
tzinfo=iso8601.UTC))['message']
created_at=datetime.datetime(
1900, 2, 1, 1, 1, 1,
tzinfo=datetime.timezone.utc))['message']
self.assertEqual([ex2], res_dict['messages'])
def test_index_with_invalid_time_format(self):

View File

@@ -3,7 +3,6 @@ hacking>=6.1.0,<6.2.0 # Apache-2.0
coverage>=5.2.1 # Apache-2.0
ddt>=1.4.1 # MIT
fixtures>=3.0.0 # Apache-2.0/BSD
iso8601>=0.1.12 # MIT
oslotest>=4.4.1 # Apache-2.0
# Do not remove 'PyMySQL' and 'psycopg2-binary' dependencies. They are used