diff --git a/openstackclient/compute/v2/usage.py b/openstackclient/compute/v2/usage.py index 3b8bda2d15..c89296794a 100644 --- a/openstackclient/compute/v2/usage.py +++ b/openstackclient/compute/v2/usage.py @@ -153,7 +153,6 @@ class ListUsage(command.Lister): ) date_cli_format = "%Y-%m-%d" - date_api_format = "%Y-%m-%dT%H:%M:%S" now = datetime.datetime.utcnow() if parsed_args.start: @@ -170,8 +169,8 @@ class ListUsage(command.Lister): usage_list = list( compute_client.usages( - start=start.strftime(date_api_format), - end=end.strftime(date_api_format), + start=start, + end=end, detailed=True, ) ) @@ -239,7 +238,6 @@ class ShowUsage(command.ShowOne): identity_client = self.app.client_manager.identity compute_client = self.app.client_manager.sdk_connection.compute date_cli_format = "%Y-%m-%d" - date_api_format = "%Y-%m-%dT%H:%M:%S" now = datetime.datetime.utcnow() if parsed_args.start: @@ -265,8 +263,8 @@ class ShowUsage(command.ShowOne): usage = compute_client.get_usage( project=project, - start=start.strftime(date_api_format), - end=end.strftime(date_api_format), + start=start, + end=end, ) if parsed_args.formatter == 'table': diff --git a/openstackclient/tests/unit/compute/v2/test_usage.py b/openstackclient/tests/unit/compute/v2/test_usage.py index ad8a8b5046..9d0ea45ccc 100644 --- a/openstackclient/tests/unit/compute/v2/test_usage.py +++ b/openstackclient/tests/unit/compute/v2/test_usage.py @@ -11,6 +11,7 @@ # under the License. # +import datetime from unittest import mock from openstackclient.compute.v2 import usage as usage_cmds @@ -94,8 +95,8 @@ class TestUsageList(TestUsage): self.projects_mock.list.assert_called_with() self.compute_sdk_client.usages.assert_called_with( - start='2016-11-11T00:00:00', - end='2016-12-20T00:00:00', + start=datetime.datetime(2016, 11, 11, 0, 0), + end=datetime.datetime(2016, 12, 20, 0, 0), detailed=True, ) @@ -190,8 +191,8 @@ class TestUsageShow(TestUsage): self.compute_sdk_client.get_usage.assert_called_with( project=self.project.id, - start='2016-11-11T00:00:00', - end='2016-12-20T00:00:00', + start=datetime.datetime(2016, 11, 11, 0, 0), + end=datetime.datetime(2016, 12, 20, 0, 0), ) self.assertEqual(self.columns, columns)