Merge "Get rid of several test dependencies"
This commit is contained in:
commit
1b077ff2b4
|
@ -13,10 +13,7 @@ pytest-html # Mozilla Public License
|
|||
pytest-xdist # MIT
|
||||
|
||||
coverage!=4.4 # Apache License, Version 2.0
|
||||
ddt # MIT
|
||||
python-dateutil # Dual License
|
||||
ddt!=1.4.0 # MIT
|
||||
testtools # MIT
|
||||
|
||||
sphinx!=1.6.6,!=1.6.7,!=2.1.0 # BSD
|
||||
oslosphinx # Apache Software License
|
||||
oslotest # Apache Software License
|
||||
docutils
|
|
@ -16,8 +16,6 @@ import copy
|
|||
import datetime as dt
|
||||
from unittest import mock
|
||||
|
||||
from dateutil import parser
|
||||
|
||||
from rally import exceptions
|
||||
from rally_openstack.task.scenarios.ceilometer import utils
|
||||
from tests.unit import test
|
||||
|
@ -25,6 +23,15 @@ from tests.unit import test
|
|||
CEILOMETER_UTILS = "rally_openstack.task.scenarios.ceilometer.utils"
|
||||
|
||||
|
||||
def get_dt_diff(dt1, dt2):
|
||||
"""Returns a diff between to datetime objects in seconds."""
|
||||
if isinstance(dt1, str):
|
||||
dt1 = dt.datetime.strptime(dt1, "%Y-%m-%dT%H:%M:%S")
|
||||
if isinstance(dt2, str):
|
||||
dt2 = dt.datetime.strptime(dt2, "%Y-%m-%dT%H:%M:%S")
|
||||
return (dt1 - dt2).seconds
|
||||
|
||||
|
||||
class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
||||
def setUp(self):
|
||||
super(CeilometerScenarioTestCase, self).setUp()
|
||||
|
@ -44,8 +51,8 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||
"resource_id": "fake_uuid",
|
||||
"timestamp": test_timestamp.isoformat()}
|
||||
self.assertEqual(expected, result[0][0])
|
||||
samples_int = (parser.parse(result[0][0]["timestamp"])
|
||||
- parser.parse(result[0][1]["timestamp"])).seconds
|
||||
samples_int = get_dt_diff(result[0][0]["timestamp"],
|
||||
result[0][1]["timestamp"])
|
||||
self.assertEqual(60, samples_int)
|
||||
|
||||
@mock.patch("%s.uuid.uuid4" % CEILOMETER_UTILS)
|
||||
|
@ -63,8 +70,8 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||
"resource_id": "fake_uuid",
|
||||
"timestamp": test_timestamp.isoformat()}
|
||||
self.assertEqual(expected, result[0][0])
|
||||
samples_int = (parser.parse(result[0][-1]["timestamp"])
|
||||
- parser.parse(result[1][0]["timestamp"])).seconds
|
||||
samples_int = get_dt_diff(result[0][-1]["timestamp"],
|
||||
result[1][0]["timestamp"])
|
||||
# NOTE(idegtiarov): here we check that interval between last sample in
|
||||
# first batch and first sample in second batch is equal 60 sec.
|
||||
self.assertEqual(60, samples_int)
|
||||
|
|
|
@ -18,7 +18,7 @@ import os
|
|||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslotest import base
|
||||
import testtools
|
||||
|
||||
from rally.common import cfg
|
||||
from rally.common import db
|
||||
|
@ -41,7 +41,7 @@ class DatabaseFixture(cfg.fixture.Config):
|
|||
db.schema_create()
|
||||
|
||||
|
||||
class TestCase(base.BaseTestCase):
|
||||
class TestCase(testtools.TestCase):
|
||||
"""Test case base class for all unit tests."""
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue