Commit 5ecc5c53 authored by Kostas Vogias's avatar Kostas Vogias Committed by Stavros Sachtouris

Test check_activation decorator

parent 7b2a99f9
......@@ -15,8 +15,6 @@
from soi.tests import fakes
from soi import storage_link, config
from mock import patch
import webob.exc
from nose.tools import assert_raises
@patch('soi.tests.fakes.DummyClass.get_from_response')
......@@ -39,19 +37,6 @@ def test_snf_get_server_volume_links(gr, gfr):
gfr.assert_called_once_with('my response', 'volumeAttachments', [])
def test_snf_get_server_volume_links_disabled():
"""Test snf_get_server_volume_links method"""
DISABLED_METHODS = ('snf_get_server_volume_links')
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
server_id = '1234'
assert_raises(webob.exc.HTTPNotImplemented,
storage_link.snf_get_server_volume_links, cls, req,
server_id)
@patch('soi.tests.fakes.DummyClass.get_from_response')
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_create_server_volume_link(gr, gfr):
......@@ -81,23 +66,6 @@ def test_snf_create_server_volume_link(gr, gfr):
gfr.assert_called_once_with('my response', 'volumeAttachment', {})
def test_snf_create_server_volume_link_disabled():
"""Test snf_create_server_volume_link method disabled"""
DISABLED_METHODS = ('snf_create_server_volume_link')
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
server_id = '1234'
volume_id = '666'
dev = ""
project_id = 'a project id'
req.environ['HTTP_X_PROJECT_ID'] = project_id
assert_raises(webob.exc.HTTPNotImplemented,
storage_link.snf_create_server_volume_link, cls, req,
server_id, volume_id, dev)
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_delete_server_volumes_link(gr):
"""Test snf_delete_server_volumes_link method"""
......@@ -116,16 +84,3 @@ def test_snf_delete_server_volumes_link(gr):
'attachment_id': volume_id}
)
gr.assert_called_once_with(cls.app)
def test_snf_delete_server_volumes_link_disabled():
"""Test snf_delete_server_volumes_link method"""
DISABLED_METHODS = ('snf_delete_server_volumes_link')
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
server_id = '1234'
volume_id = '666'
assert_raises(webob.exc.HTTPNotImplemented,
storage_link.snf_delete_server_volumes_link, cls, req,
server_id, volume_id)
......@@ -12,15 +12,19 @@
#
# You should have received a copy of the GNU General Public License
from soi import utils
from soi import utils, config
from mock import patch
from soi.tests import fakes
import webob.exc
from nose.tools import assert_raises
def test_patch_class_methods():
"""Test utils.patch_class_methods"""
class DummyClass:
"""use it for testing"""
def a_method(self, an_arg):
"""a method"""
......@@ -48,3 +52,17 @@ def test_empty_list_200(gr, gfr):
assert r == 'g f r'
gfr.assert_called_once_with('my response', 'empty list', [])
gr.assert_called_once_with(cls.app)
def test_check_activation():
"""Test check activation method"""
@utils.check_activation
def DummyMethod():
pass
func_full_name = DummyMethod.__module__ + '.' + DummyMethod.__name__
DISABLED_METHODS = (func_full_name,)
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
assert_raises(webob.exc.HTTPNotImplemented, DummyMethod)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment