Skip to content

Commit

Permalink
Lazy initialization makes partial test faster
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed Nov 5, 2021
1 parent 425a908 commit 5271e1f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ class TestApplicationForRefreshInBehaviors(unittest.TestCase):
account = {"home_account_id": "{}.{}".format(uid, utid)}
rt = "this is a rt"
client_id = "my_app"
app = ClientApplication(client_id, authority=authority_url)

@classmethod
def setUpClass(cls): # Initialization at runtime, not interpret-time
cls.app = ClientApplication(cls.client_id, authority=cls.authority_url)

def setUp(self):
self.app.token_cache = self.cache = msal.SerializableTokenCache()
Expand Down Expand Up @@ -485,8 +488,10 @@ def mock_post(url, headers=None, *args, **kwargs):


class TestTelemetryOnClientApplication(unittest.TestCase):
app = ClientApplication(
"client_id", authority="https://login.microsoftonline.com/common")
@classmethod
def setUpClass(cls): # Initialization at runtime, not interpret-time
cls.app = ClientApplication(
"client_id", authority="https://login.microsoftonline.com/common")

def test_acquire_token_by_auth_code_flow(self):
at = "this is an access token"
Expand All @@ -509,8 +514,10 @@ def mock_post(url, headers=None, *args, **kwargs):


class TestTelemetryOnPublicClientApplication(unittest.TestCase):
app = PublicClientApplication(
"client_id", authority="https://login.microsoftonline.com/common")
@classmethod
def setUpClass(cls): # Initialization at runtime, not interpret-time
cls.app = PublicClientApplication(
"client_id", authority="https://login.microsoftonline.com/common")

# For now, acquire_token_interactive() is verified by code review.

Expand All @@ -534,9 +541,11 @@ def mock_post(url, headers=None, *args, **kwargs):


class TestTelemetryOnConfidentialClientApplication(unittest.TestCase):
app = ConfidentialClientApplication(
"client_id", client_credential="secret",
authority="https://login.microsoftonline.com/common")
@classmethod
def setUpClass(cls): # Initialization at runtime, not interpret-time
cls.app = ConfidentialClientApplication(
"client_id", client_credential="secret",
authority="https://login.microsoftonline.com/common")

def test_acquire_token_for_client(self):
at = "this is an access token"
Expand Down

0 comments on commit 5271e1f

Please sign in to comment.