Added unit test for the sample middleware component; Tweaks to the Barbican worker node boot script;
This commit is contained in:
parent
f6aa3f5868
commit
2fd5cd145b
41
barbican/tests/api/middleware_test.py
Normal file
41
barbican/tests/api/middleware_test.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013 Rackspace, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT 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 unittest
|
||||
from mock import MagicMock
|
||||
from barbican.api.middleware.simple import SimpleFilter
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
suite.addTest(WhenTestingSimpleMiddleware())
|
||||
|
||||
return suite
|
||||
|
||||
|
||||
class WhenTestingSimpleMiddleware(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.app = MagicMock()
|
||||
self.middle = SimpleFilter(self.app)
|
||||
self.req = MagicMock()
|
||||
|
||||
def test_process_request(self):
|
||||
self.middle.process_request(self.req)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -24,7 +24,8 @@ import gettext
|
||||
import os
|
||||
import sys
|
||||
|
||||
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
||||
# 'Borrowed' from the Glance project:
|
||||
# If ../barbican/__init__.py exists, add ../ to Python search path, so that
|
||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||
os.pardir,
|
||||
@ -41,6 +42,7 @@ from barbican.common import exception
|
||||
from barbican.openstack.common import log
|
||||
from barbican.queue.celery.resources import celery
|
||||
|
||||
|
||||
def fail(returncode, e):
|
||||
sys.stderr.write("ERROR: {0}\n".format(e))
|
||||
sys.exit(returncode)
|
||||
@ -50,7 +52,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
config.parse_args()
|
||||
log.setup('barbican')
|
||||
|
||||
|
||||
celery.worker_main()
|
||||
except RuntimeError as e:
|
||||
fail(1, e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user