From cf2927417183c4d4fc7b288dda9af02be1a143ee Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 27 Jul 2016 17:02:33 +0200 Subject: Avoid useless dependency on oslo_utils Change-Id: Icba21e8b487c2b9a2064212ee2c550ced4be1d2e --- ceilometermiddleware/swift.py | 4 ++-- ceilometermiddleware/tests/test_swift.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'ceilometermiddleware') diff --git a/ceilometermiddleware/swift.py b/ceilometermiddleware/swift.py index f9c7605..e6baa81 100644 --- a/ceilometermiddleware/swift.py +++ b/ceilometermiddleware/swift.py @@ -45,12 +45,12 @@ before "proxy-server" and add the following filter in the file: # Logging level control log_level = WARNING """ +import datetime import functools import logging from oslo_config import cfg import oslo_messaging -from oslo_utils import timeutils from pycadf import event as cadf_event from pycadf.helper import api from pycadf import measurement as cadf_measurement @@ -231,7 +231,7 @@ class Swift(object): except ValueError: return - now = timeutils.utcnow().isoformat() + now = datetime.datetime.utcnow().isoformat() resource_metadata = { "path": path, diff --git a/ceilometermiddleware/tests/test_swift.py b/ceilometermiddleware/tests/test_swift.py index 4c0f43e..8e9cbf7 100644 --- a/ceilometermiddleware/tests/test_swift.py +++ b/ceilometermiddleware/tests/test_swift.py @@ -12,10 +12,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - import mock from oslo_config import cfg -from oslo_utils import timeutils import six from ceilometermiddleware import swift @@ -312,9 +310,9 @@ class TestSwift(tests_base.TestCase): list(app(req.environ, self.start_response)) self.assertEqual(0, len(notify.call_args_list)) - @mock.patch.object(timeutils, 'utcnow') - def test_emit_event_fail(self, mocked_time): - mocked_time.side_effect = Exception("a exception") + @mock.patch('six.moves.urllib.parse.quote') + def test_emit_event_fail(self, mocked_func): + mocked_func.side_effect = Exception("a exception") app = swift.Swift(FakeApp(body=["test"]), {}) req = FakeRequest('/1.0/account/container', environ={'REQUEST_METHOD': 'GET'}) -- cgit v1.2.1