Mark other API related tests with mox free

Change-Id: I991100bce99815bbd5af078e53b966c5cfc92233
Partially-Implements: blueprint mock-framework-in-unit-tests
This commit is contained in:
Akihiro Motoki 2017-12-30 19:48:01 +09:00
parent 5c5159bc09
commit d3883a147b
6 changed files with 32 additions and 0 deletions

View File

@ -25,6 +25,8 @@ from openstack_dashboard.test import helpers as test
class CinderRestTestCase(test.TestCase):
use_mox = False
#
# Volumes
#

View File

@ -17,6 +17,9 @@ from openstack_dashboard.test import helpers as test
class ConfigRestTestCase(test.TestCase):
use_mox = False
def test_settings_config_get(self):
request = self.mock_rest_request()
response = config.Settings().get(request)

View File

@ -20,6 +20,9 @@ from openstack_dashboard.test import helpers as test
class ImagesRestTestCase(test.ResetImageAPIVersionMixin, test.TestCase):
use_mox = False
def setUp(self):
super(ImagesRestTestCase, self).setUp()
api.glance.VERSIONS.clear_active_cache()

View File

@ -20,6 +20,8 @@ from openstack_dashboard.test import helpers as test
class PolicyRestTestCase(test.TestCase):
use_mox = False
@override_settings(POLICY_CHECK_FUNCTION='openstack_auth.policy.check')
def _test_policy(self, body, expected=True):
request = self.mock_rest_request(body=body)

View File

@ -17,6 +17,9 @@ from openstack_dashboard.test import helpers as test
class RestUtilsTestCase(test.TestCase):
use_mox = False
def test_api_success(self):
@utils.ajax()
def f(self, request):
@ -169,6 +172,9 @@ class RestUtilsTestCase(test.TestCase):
class JSONEncoderTestCase(test.TestCase):
use_mox = False
# NOTE(tsufiev): NaN numeric is "conventional" in a sense that the custom
# NaNJSONEncoder encoder translates it to the same token that the standard
# JSONEncoder encoder does

View File

@ -59,6 +59,9 @@ class APIDict(api_base.APIDictWrapper):
class APIVersionTests(test.TestCase):
use_mox = False
def test_equal(self):
version = api_base.Version('1.0')
self.assertEqual(1, version)
@ -105,6 +108,9 @@ class APIVersionTests(test.TestCase):
# Wrapper classes that only define _attrs don't need extra testing.
class APIResourceWrapperTests(test.TestCase):
use_mox = False
def test_get_attribute(self):
resource = APIResource.get_instance()
self.assertEqual('foo', resource.foo)
@ -131,6 +137,9 @@ class APIResourceWrapperTests(test.TestCase):
class APIDictWrapperTests(test.TestCase):
use_mox = False
# APIDict allows for both attribute access and dictionary style [element]
# style access. Test both
def test_get_item(self):
@ -198,6 +207,9 @@ class APIDictWrapperTests(test.TestCase):
class ApiVersionTests(test.TestCase):
use_mox = False
def setUp(self):
super(ApiVersionTests, self).setUp()
self.previous_settings = settings.OPENSTACK_API_VERSIONS
@ -235,6 +247,8 @@ class ApiVersionTests(test.TestCase):
class ApiHelperTests(test.TestCase):
"""Tests for functions that don't use one of the api objects."""
use_mox = False
def test_url_for(self):
url = api_base.url_for(self.request, 'image')
self.assertEqual('http://public.glance.example.com:9292', url)
@ -290,6 +304,8 @@ class ApiHelperTests(test.TestCase):
class QuotaSetTests(test.TestCase):
use_mox = False
def test_quotaset_add_with_plus(self):
quota_dict = {'foo': 1, 'bar': 10}
other_quota_dict = {'my_test': 12}