Fix: test_authenticate_wrong_credentials is not marked as an Internet test.

This commit is contained in:
joo 2018-01-13 02:36:57 +00:00
parent bfaabcad58
commit 0ec2398fb4
1 changed files with 10 additions and 18 deletions

View File

@ -47,22 +47,14 @@ def get_mc_credentials():
username, password = get_mc_credentials()
def should_skip_cred_test():
"""
Returns `True` if a test requiring credentials should be skipped.
Otherwise returns `False`
"""
if username is None or password is None:
return True
return False
skipIfNoCredentials = unittest.skipIf(
username is None or password is None,
"Need credentials to perform test.")
def should_run_internet_tests():
"""
Returns `True` if tests involving access to Internet resources
should *not* be skipped. Otherwise returns `False`.
"""
return os.environ.get('PYCRAFT_RUN_INTERNET_TESTS')
skipUnlessInternetTestsEnabled = unittest.skipUnless(
os.environ.get('PYCRAFT_RUN_INTERNET_TESTS'),
"Tests involving Internet access are disabled.")
class InitProfile(unittest.TestCase):
@ -184,6 +176,7 @@ class AuthenticateAuthenticationToken(unittest.TestCase):
with self.assertRaises(TypeError):
a.authenticate("username")
@skipUnlessInternetTestsEnabled
def test_authenticate_wrong_credentials(self):
a = AuthenticationToken()
@ -196,8 +189,8 @@ class AuthenticateAuthenticationToken(unittest.TestCase):
self.maxDiff = 5000
self.assertEqual(str(cm.exception), err)
@unittest.skipIf(should_skip_cred_test(),
"Need credentials to perform test.")
@skipIfNoCredentials
@skipUnlessInternetTestsEnabled
def test_authenticate_good_credentials(self):
a = AuthenticationToken()
@ -205,8 +198,7 @@ class AuthenticateAuthenticationToken(unittest.TestCase):
self.assertTrue(resp)
@unittest.skipUnless(should_run_internet_tests(),
"Tests involving Internet access are disabled.")
@skipUnlessInternetTestsEnabled
class MakeRequest(unittest.TestCase):
def test_make_request_http_method(self):
res = _make_request(AUTHSERVER, "authenticate", {"Billy": "Bob"})