Move common/utils tests to top level test folder

Moves common/utils tests out of the test folder in that directory and
into the root tests folder, where tox and Jenkins can pick them up.

Change-Id: I28222a1839102a0973712d72bfcb365b5e4bc4b5
This commit is contained in:
Nicholas Jones 2017-08-10 14:41:11 -05:00
parent 77341ef4b7
commit 6ac6193118
8 changed files with 37 additions and 35 deletions

View File

@ -6,9 +6,9 @@ import threading
import time
import urllib2
from audit_client.api.exceptions.audit_exception import AuditException
from audit_client.api.model.get_audits_result import AuditsResult
from audit_client.api.model.transaction import Transaction
from orm.common.client.audit.audit_client.api.exceptions.audit_exception import AuditException
from orm.common.client.audit.audit_client.api.model.get_audits_result import AuditsResult
from orm.common.client.audit.audit_client.api.model.transaction import Transaction
logger = logging.getLogger(__name__)

View File

@ -1,6 +1,6 @@
import json
from orm_common.utils import utils
from orm.common.orm_common.utils import utils
from wsme.exc import ClientSideError

View File

@ -4,7 +4,7 @@ import time
import requests
from audit_client.api import audit
from orm.common.client.audit.audit_client.api import audit
from pecan import conf
# from cms_rest.logger import get_logger

View File

@ -2,7 +2,7 @@ import json
from unittest import TestCase
import mock
from orm_common.utils import api_error_utils
from orm.common.orm_common.utils import api_error_utils
class TestCrossApiUtil(TestCase):

View File

@ -2,7 +2,7 @@ import time
from unittest import TestCase
import mock
from orm_common.utils import cross_api_utils
from orm.common.orm_common.utils import cross_api_utils
class TestCrossApiUtil(TestCase):
@ -24,25 +24,25 @@ class TestCrossApiUtil(TestCase):
cross_api_utils.set_utils_conf(None)
self.assertRaises(AssertionError, cross_api_utils._check_conf_initialization)
@mock.patch('orm_common.utils.cross_api_utils.get_rms_region_group')
@mock.patch('orm.common.orm_common.utils.cross_api_utils.get_rms_region_group')
def test_is_region_group_exist(self, mock_rms_region_group):
mock_rms_region_group.return_value = 'test_group'
exist = cross_api_utils.is_region_group_exist('test_group_name')
self.assertEqual(exist, True)
@mock.patch('orm_common.utils.cross_api_utils.get_rms_region_group')
@mock.patch('orm.common.orm_common.utils.cross_api_utils.get_rms_region_group')
def test_is_region_group_exist_false(self, mock_rms_region_group):
mock_rms_region_group.return_value = None
exist = cross_api_utils.is_region_group_exist('test_group_name')
self.assertEqual(exist, False)
@mock.patch('orm_common.utils.cross_api_utils.get_rms_region_group')
@mock.patch('orm.common.orm_common.utils.cross_api_utils.get_rms_region_group')
def test_get_regions_of_group(self, mock_rms_region_group):
mock_rms_region_group.return_value = {'regions': 'group'}
exist = cross_api_utils.get_regions_of_group('test_group_name')
self.assertEqual(exist, 'group')
@mock.patch('orm_common.utils.cross_api_utils.get_rms_region_group')
@mock.patch('orm.common.orm_common.utils.cross_api_utils.get_rms_region_group')
def test_get_regions_of_group_false(self, mock_rms_region_group):
mock_rms_region_group.return_value = None
exist = cross_api_utils.get_regions_of_group('test_group_name')

View File

@ -3,7 +3,7 @@ import pprint
from unittest import TestCase
import mock
from orm_common.utils import utils
from orm.common.orm_common.utils import utils
from testfixtures import log_capture
@ -25,12 +25,12 @@ class TestUtil(TestCase):
self.assertEqual(uuid, '987654321')
@mock.patch('requests.post')
@log_capture('orm_common.utils.utils', level=logging.INFO)
@log_capture('orm.common.orm_common.utils.utils', level=logging.INFO)
def test_make_uuid_offline(self, mock_post, l):
mock_post.side_effect = Exception('boom')
uuid = utils.make_uuid()
self.assertEqual(uuid, None)
l.check(('orm_common.utils.utils', 'INFO', 'Failed in make_uuid:boom'))
l.check(('orm.common.orm_common.utils.utils', 'INFO', 'Failed in make_uuid:boom'))
@mock.patch('requests.post')
def test_make_transid(self, mock_post):
@ -39,33 +39,34 @@ class TestUtil(TestCase):
self.assertEqual(uuid, '987654321')
@mock.patch('requests.post')
@log_capture('orm_common.utils.utils', level=logging.INFO)
@log_capture('orm.common.orm_common.utils.utils', level=logging.INFO)
def test_make_transid_offline(self, mock_post, l):
mock_post.side_effect = Exception('boom')
uuid = utils.make_transid()
self.assertEqual(uuid, None)
l.check(
('orm_common.utils.utils', 'INFO', 'Failed in make_transid:boom'))
('orm.common.orm_common.utils.utils', 'INFO', 'Failed in make_transid:boom'))
@mock.patch('audit_client.api.audit.init')
@mock.patch('audit_client.api.audit.audit')
@mock.patch('orm.common.client.audit.audit_client.api.audit.init')
@mock.patch('orm.common.client.audit.audit_client.api.audit.audit')
def test_audit_trail(self, mock_init, mock_audit):
resp = utils.audit_trail('create customer', '1234',
{'X-RANGER-Client': 'Fred'}, '5678')
self.assertEqual(resp, 200)
@mock.patch('audit_client.api.audit.audit')
@mock.patch('orm.common.client.audit.audit_client.api.audit.audit')
def test_audit_trail_offline(self, mock_audit):
mock_audit.side_effect = Exception('boom')
resp = utils.audit_trail('create customer', '1234',
{'X-RANGER-Client': 'Fred'}, '5678')
self.assertEqual(resp, None)
@mock.patch('audit_client.api.audit.init')
@mock.patch('audit_client.api.audit.audit')
@mock.patch('orm.common.client.audit.audit_client.api.audit.init')
@mock.patch('orm.common.client.audit.audit_client.api.audit.audit')
def test_audit_service_args_least(self, mock_audit, mock_init):
resp = utils.audit_trail('create customer', '1234',
{'X-RANGER-Client': 'Fred'}, '5678')
{'X-RANGER-Client': 'Fred'}, '5678',
event_details='CMS')
self.assertEqual(mock_audit.call_args[0][1], 'Fred') # application_id
self.assertEqual(mock_audit.call_args[0][2], '1234') # tracking_id
self.assertEqual(mock_audit.call_args[0][3], '1234') # transaction_id
@ -78,12 +79,13 @@ class TestUtil(TestCase):
self.assertEqual(mock_audit.call_args[0][9], 'CMS') # event_details
# self.assertEqual(mock_audit.call_args[0][10], 'Saved to DB') # status
@mock.patch('audit_client.api.audit.init')
@mock.patch('audit_client.api.audit.audit')
@mock.patch('orm.common.client.audit.audit_client.api.audit.init')
@mock.patch('orm.common.client.audit.audit_client.api.audit.audit')
def test_audit_service_with_tracking(self, mock_audit, mock_init):
utils.audit_trail('create customer', '1234',
{'X-RANGER-Client': 'Fred',
'X-RANGER-Tracking-Id': 'Track12'}, '5678')
'X-RANGER-Tracking-Id': 'Track12'}, '5678',
event_details='CMS')
self.assertEqual(mock_audit.call_args[0][1], 'Fred') # application_id
self.assertEqual(mock_audit.call_args[0][2], 'Track12') # tracking_id
self.assertEqual(mock_audit.call_args[0][3], '1234') # transaction_id
@ -96,12 +98,13 @@ class TestUtil(TestCase):
self.assertEqual(mock_audit.call_args[0][9], 'CMS') # event_details
# self.assertEqual(mock_audit.call_args[0][10], 'Saved to DB') # status
@mock.patch('audit_client.api.audit.init')
@mock.patch('audit_client.api.audit.audit')
@mock.patch('orm.common.client.audit.audit_client.api.audit.init')
@mock.patch('orm.common.client.audit.audit_client.api.audit.audit')
def test_audit_service_with_requester(self, mock_audit, mock_init):
resp = utils.audit_trail('create customer', '1234',
{'X-RANGER-Client': 'Fred',
'X-RANGER-Requester': 'Req04'}, '5678')
'X-RANGER-Requester': 'Req04'}, '5678',
event_details='CMS')
self.assertEqual(mock_audit.call_args[0][1], 'Fred') # application_id
self.assertEqual(mock_audit.call_args[0][2], '1234') # tracking_id
self.assertEqual(mock_audit.call_args[0][3], '1234') # transaction_id

View File

@ -5,13 +5,12 @@
hacking>=0.12.0,<0.13 # Apache-2.0
coverage>=4.0,!=4.4 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
sphinx>=1.6.2 # BSD
openstackdocstheme>=1.11.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
os-testr>=0.8.0 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
reno>=1.8.0 # Apache-2.0
sphinx>=1.6.2 # BSD
testfixtures>=5.1.1 # MIT
testrepository>=0.0.18 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
openstackdocstheme>=1.11.0 # Apache-2.0
os-testr>=0.8.0 # Apache-2.0
# releasenotes
reno>=1.8.0 # Apache-2.0