Skip to content

Commit

Permalink
Change user agent for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jun 14, 2021
1 parent ae48c7e commit c2b7b78
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/test_authenticator.py
Expand Up @@ -9,7 +9,7 @@

class TrustedAuthenticatorTest(asynctest.TestCase):
async def setUp(self) -> None:
self.requestor = Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = Requestor("asyncprawcore:test (by /u/Lil_SpazJoekp)")

async def tearDown(self) -> None:
await self.requestor.close()
Expand Down Expand Up @@ -78,7 +78,7 @@ async def test_revoke_token__with_refresh_token_hint(self):

class UntrustedAuthenticatorTest(asynctest.TestCase):
async def setUp(self) -> None:
self.requestor = Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = Requestor("asyncprawcore:test (by /u/Lil_SpazJoekp)")

async def tearDown(self) -> None:
await self.requestor.close()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_authorizer.py
Expand Up @@ -19,7 +19,7 @@

class AuthorizerTestBase(asynctest.TestCase):
async def setUp(self):
self.requestor = Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = Requestor("asyncprawcore:test (by /u/Lil_SpazJoekp)")
self.authentication = asyncprawcore.TrustedAuthenticator(
self.requestor, CLIENT_ID, CLIENT_SECRET
)
Expand Down Expand Up @@ -257,7 +257,7 @@ async def test_revoke__without_any_token(self):

class DeviceIDAuthorizerTest(AuthorizerTestBase):
async def setUp(self):
self.requestor = Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = Requestor("asyncprawcore:test (by /u/Lil_SpazJoekp)")

self.authentication = asyncprawcore.UntrustedAuthenticator(
self.requestor, CLIENT_ID
Expand Down
14 changes: 9 additions & 5 deletions tests/test_requestor.py
Expand Up @@ -16,9 +16,11 @@ async def tearDown(self) -> None:
await self.requestor.close()

async def test_initialize(self):
self.requestor = asyncprawcore.Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = asyncprawcore.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)
self.assertEqual(
f"asyncprawcore:test (by /u/bboe) asyncprawcore/{asyncprawcore.__version__}",
f"asyncprawcore:test (by /u/Lil_SpazJoekp) asyncprawcore/{asyncprawcore.__version__}",
self.requestor._http._default_headers["User-Agent"],
)

Expand All @@ -32,7 +34,9 @@ async def test_request__wrap_request_exceptions(self, mock_session):
exception = Exception("asyncprawcore wrap_request_exceptions")
session_instance = mock_session.return_value
session_instance.request.side_effect = exception
self.requestor = asyncprawcore.Requestor("asyncprawcore:test (by /u/bboe)")
self.requestor = asyncprawcore.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)
with self.assertRaises(asyncprawcore.RequestException) as context_manager:
await self.requestor.request("get", "http://a.b", data="bar")
self.assertIsInstance(context_manager.exception, RequestException)
Expand All @@ -53,11 +57,11 @@ async def test_request__use_custom_session(self):
session = Mock(**attrs)

self.requestor = asyncprawcore.Requestor(
"asyncprawcore:test (by /u/bboe)", session=session
"asyncprawcore:test (by /u/Lil_SpazJoekp)", session=session
)

self.assertEqual(
f"asyncprawcore:test (by /u/bboe) asyncprawcore/{asyncprawcore.__version__}",
f"asyncprawcore:test (by /u/Lil_SpazJoekp) asyncprawcore/{asyncprawcore.__version__}",
self.requestor._http._default_headers["User-Agent"],
)
self.assertEqual(
Expand Down
18 changes: 13 additions & 5 deletions tests/test_sessions.py
Expand Up @@ -24,7 +24,9 @@

class InvalidAuthorizer(asyncprawcore.Authorizer):
def __init__(self):
requestor = asyncprawcore.requestor.Requestor("asyncprawcore:test (by /u/bboe)")
requestor = asyncprawcore.requestor.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)

super(InvalidAuthorizer, self).__init__(
asyncprawcore.TrustedAuthenticator(requestor, CLIENT_ID, CLIENT_SECRET)
Expand All @@ -35,7 +37,9 @@ def is_valid(self):


async def client_authorizer():
requestor = asyncprawcore.requestor.Requestor("asyncprawcore:test (by /u/bboe)")
requestor = asyncprawcore.requestor.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)

authenticator = asyncprawcore.TrustedAuthenticator(
requestor, CLIENT_ID, CLIENT_SECRET
Expand All @@ -46,7 +50,9 @@ async def client_authorizer():


async def readonly_authorizer(refresh=True):
requestor = asyncprawcore.requestor.Requestor("asyncprawcore:test (by /u/bboe)")
requestor = asyncprawcore.requestor.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)
authenticator = asyncprawcore.TrustedAuthenticator(
requestor, CLIENT_ID, CLIENT_SECRET
)
Expand All @@ -57,7 +63,9 @@ async def readonly_authorizer(refresh=True):


async def script_authorizer():
requestor = asyncprawcore.requestor.Requestor("asyncprawcore:test (by /u/bboe)")
requestor = asyncprawcore.requestor.Requestor(
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)
authenticator = asyncprawcore.TrustedAuthenticator(
requestor, CLIENT_ID, CLIENT_SECRET
)
Expand All @@ -69,7 +77,7 @@ async def script_authorizer():
class SessionTest(asynctest.TestCase):
async def setUp(self) -> None:
self.requestor = asyncprawcore.requestor.Requestor(
"asyncprawcore:test (by /u/bboe)"
"asyncprawcore:test (by /u/Lil_SpazJoekp)"
)

async def tearDown(self) -> None:
Expand Down

0 comments on commit c2b7b78

Please sign in to comment.