Skip to content

Commit

Permalink
Merge pull request #316 from bug-or-feature/invalid_token
Browse files Browse the repository at this point in the history
logout integration test exits after 3 attempts
  • Loading branch information
bug-or-feature authored Dec 4, 2023
2 parents a0ada1d + bdc7236 commit b19f0c9
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from random import randint, choice
import logging
import time
from tenacity import Retrying, wait_exponential, retry_if_exception_type
from tenacity import (
Retrying,
wait_exponential,
retry_if_exception_type,
stop_after_attempt,
)


RETRYABLE = (ApiExceededException, TokenInvalidException)
Expand All @@ -26,6 +31,16 @@ def retrying():
)


@pytest.fixture(scope="module")
def limited_retrying():
"""test fixture creates a tenacity.Retrying instance with max 3 attempts"""
return Retrying(
wait=wait_exponential(),
retry=retry_if_exception_type(RETRYABLE),
stop=stop_after_attempt(3),
)


@pytest.fixture(autouse=True)
def logging_setup():
"""sets logging for each test"""
Expand Down Expand Up @@ -844,13 +859,13 @@ def test_update_client_app(self, ig_service: IGService):
result = ig_service.update_client_app(60, 60, config.api_key, "ENABLED")
print(result)

def test_logout(self, retrying):
def test_logout(self, limited_retrying):
ig_service = IGService(
config.username,
config.password,
config.api_key,
config.acc_type,
retryer=retrying,
retryer=limited_retrying,
)
ig_service.create_session()
ig_service.logout()
Expand Down

0 comments on commit b19f0c9

Please sign in to comment.