Fix: test_authenticate_wrong_credentials is not marked as an Internet test.

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