Allow tox to run without errors / failures

- fixes the test code to allow flake8 to run on it and pass.
- allow auth to be imported without a loaded config

Change-Id: I71c9d8e7e672cd1dac1fbf7f1d73056ebb625a22
This commit is contained in:
Bryan D. Payne 2015-02-17 16:12:05 -08:00
parent fcf1473004
commit 3fe4bdcaf9
3 changed files with 16 additions and 11 deletions

View File

@ -16,11 +16,17 @@ from .results import AuthDetails
from pecan import conf
if conf.auth.get('ldap'):
from . import ldap
try:
if conf.auth.get('ldap'):
from . import ldap
except AttributeError:
pass # config not loaded
if conf.auth.get('keystone'):
from . import keystone
try:
if conf.auth.get('keystone'):
from . import keystone
except AttributeError:
pass # config not loaded
def validate(user, secret):

View File

@ -15,6 +15,7 @@
# under the License.
import unittest
import mock
from anchor.X509 import errors as x509_errors

View File

@ -13,10 +13,10 @@
# 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 mock
import unittest
from pecan import conf
import mock
class AuthInitTests(unittest.TestCase):
@ -28,13 +28,11 @@ class AuthInitTests(unittest.TestCase):
pass
def test_validate_static(self):
"""Test all static user/pass authentication paths.
"""
"""Test all static user/pass authentication paths."""
config = 'pecan.conf.__values__'
data = {'auth': {'static': {'secret': 'simplepassword',
'user': 'myusername'},
}
}
'user': 'myusername'}}}
with mock.patch.dict(config, data):
# can't import until mock'd
from anchor import auth