diff --git a/kibicara/config.py b/kibicara/config.py index 47237c0..1ecc7c6 100644 --- a/kibicara/config.py +++ b/kibicara/config.py @@ -57,8 +57,8 @@ if argv[0].endswith('kibicara'): parser.add_argument( '-v', '--verbose', - action="count", - help="Raise verbosity level", + action='count', + help='Raise verbosity level', ) args = parser.parse_args() @@ -72,7 +72,7 @@ if argv[0].endswith('kibicara_mda'): help='path to config file', ) # the MDA passes the recipient address as command line argument - parser.add_argument("recipient") + parser.add_argument('recipient') args = parser.parse_args() if args is not None: diff --git a/kibicara/kibicara.py b/kibicara/kibicara.py index 0e38e8b..7f07555 100644 --- a/kibicara/kibicara.py +++ b/kibicara/kibicara.py @@ -40,7 +40,7 @@ class Main: } basicConfig( level=LOGLEVELS.get(args.verbose, DEBUG), - format="%(asctime)s %(name)s %(message)s", + format='%(asctime)s %(name)s %(message)s', ) getLogger('aiosqlite').setLevel(WARNING) Mapping.create_all() @@ -71,8 +71,8 @@ class Main: CORSMiddleware, allow_origins=config['cors_allow_origin'], allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], + allow_methods=['*'], + allow_headers=['*'], ) if config['frontend_path'] is not None: app.mount( diff --git a/kibicara/platforms/email/bot.py b/kibicara/platforms/email/bot.py index 4594451..8d75b0c 100644 --- a/kibicara/platforms/email/bot.py +++ b/kibicara/platforms/email/bot.py @@ -51,11 +51,11 @@ class EmailBot(Censor): logger.debug('Trying to send: \n{0}'.format(body)) email.send_email( subscriber.email, - "Kibicara {0}".format(self.hood.name), + 'Kibicara {0}'.format(self.hood.name), body=body, ) except (ConnectionRefusedError, SMTPException): - logger.exception("Sending email to subscriber failed.") + logger.exception('Sending email to subscriber failed.') spawner = Spawner(Hood, EmailBot) diff --git a/kibicara/platforms/email/webapi.py b/kibicara/platforms/email/webapi.py index 0f69b65..bf8902f 100644 --- a/kibicara/platforms/email/webapi.py +++ b/kibicara/platforms/email/webapi.py @@ -202,17 +202,19 @@ async def email_subscribe( raise HTTPException(status_code=status.HTTP_409_CONFLICT) email.send_email( subscriber.email, - "Subscribe to Kibicara {0}".format(hood.name), - body='To confirm your subscription, follow this link: {0}'.format(confirm_link), + 'Subscribe to Kibicara {0}'.format(hood.name), + body='To confirm your subscription, follow this link: {0}'.format( + confirm_link + ), ) return {} except ConnectionRefusedError: logger.info(token) - logger.error("Sending subscription confirmation email failed.", exc_info=True) + logger.error('Sending subscription confirmation email failed.', exc_info=True) raise HTTPException(status_code=status.HTTP_502_BAD_GATEWAY) except SMTPException: logger.info(token) - logger.error("Sending subscription confirmation email failed.", exc_info=True) + logger.error('Sending subscription confirmation email failed.', exc_info=True) raise HTTPException(status_code=status.HTTP_502_BAD_GATEWAY) @@ -252,7 +254,7 @@ async def email_unsubscribe(token, hood=Depends(get_hood_unauthorized)): :param hood: Hood the Email bot belongs to. """ try: - logger.warning("token is: {0}".format(token)) + logger.warning('token is: {0}'.format(token)) payload = from_token(token) # If token.hood and url.hood are different, raise an error: if hood.id is not payload['hood']: @@ -305,14 +307,14 @@ async def email_message_create( if message.secret == receiver.secret: # pass message.text to bot.py if await spawner.get(hood).publish(Message(message.text)): - logger.warning("Message was accepted: {0}".format(message.text)) + logger.warning('Message was accepted: {0}'.format(message.text)) return {} else: - logger.warning("Message was't accepted: {0}".format(message.text)) + logger.warning('Message was\'t accepted: {0}'.format(message.text)) raise HTTPException( status_code=status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS ) logger.warning( - "Someone is trying to submit an email without the correct API secret" + 'Someone is trying to submit an email without the correct API secret' ) raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED) diff --git a/kibicara/platforms/twitter/bot.py b/kibicara/platforms/twitter/bot.py index b07d302..bbad787 100644 --- a/kibicara/platforms/twitter/bot.py +++ b/kibicara/platforms/twitter/bot.py @@ -129,7 +129,7 @@ class TwitterBot(Censor): remove_indices.update(range(url.indices[0], url.indices[1] + 1)) for symbol in entities.symbols: remove_indices.update(range(symbol.indices[0], symbol.indices[1] + 1)) - filtered_text = "" + filtered_text = '' for index, character in enumerate(text): if index not in remove_indices: filtered_text += character diff --git a/kibicara/platforms/twitter/webapi.py b/kibicara/platforms/twitter/webapi.py index 587191a..c02e9cf 100644 --- a/kibicara/platforms/twitter/webapi.py +++ b/kibicara/platforms/twitter/webapi.py @@ -130,8 +130,8 @@ async def twitter_create(response: Response, hood=Depends(get_hood)): request_token = await get_oauth_token( config['twitter']['consumer_key'], config['twitter']['consumer_secret'], - callback_uri="{0}/dashboard/twitter-callback?hood={1}".format( - config["frontend_url"], hood.id + callback_uri='{0}/dashboard/twitter-callback?hood={1}'.format( + config['frontend_url'], hood.id ), ) if request_token['oauth_callback_confirmed'] != 'true': diff --git a/kibicara/webapi/admin.py b/kibicara/webapi/admin.py index 7956688..55178a8 100644 --- a/kibicara/webapi/admin.py +++ b/kibicara/webapi/admin.py @@ -111,7 +111,7 @@ async def admin_register(values: BodyAdmin): admin = await Admin.objects.filter(email=values.email).all() if admin: raise HTTPException(status_code=status.HTTP_409_CONFLICT) - body = '{0}/confirm?token={1}'.format(config["frontend_url"], register_token) + body = '{0}/confirm?token={1}'.format(config['frontend_url'], register_token) logger.debug(body) email.send_email( to=values.email, @@ -183,7 +183,9 @@ async def admin_reset_password(values: BodyEmail): admin = await Admin.objects.filter(email=values.email).all() if not admin: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) - body = '{0}/password-reset?token={1}'.format(config["frontend_url"], register_token) + body = '{0}/password-reset?token={1}'.format( + config['frontend_url'], register_token + ) logger.debug(body) email.send_email( to=values.email, diff --git a/tests/tests_email/conftest.py b/tests/tests_email/conftest.py index f85adfa..34e4f75 100644 --- a/tests/tests_email/conftest.py +++ b/tests/tests_email/conftest.py @@ -9,7 +9,7 @@ from fastapi import status from pytest import fixture -@fixture(scope="function") +@fixture(scope='function') def email_row(client, hood_id, auth_header): response = client.post( '/api/hoods/{0}/email/'.format(hood_id), diff --git a/tests/tests_email/test_api_email_happy_path.py b/tests/tests_email/test_api_email_happy_path.py index 7a2557b..5ee06f7 100644 --- a/tests/tests_email/test_api_email_happy_path.py +++ b/tests/tests_email/test_api_email_happy_path.py @@ -41,8 +41,8 @@ def test_email_subscribe_unsubscribe(client, hood_id, receive_email): def test_email_message(client, hood_id, trigger_id, email_row): body = { - 'text': "test", - 'author': "test@localhost", + 'text': 'test', + 'author': 'test@localhost', 'secret': email_row['secret'], } response = client.post('/api/hoods/{0}/email/messages/'.format(hood_id), json=body) @@ -78,6 +78,6 @@ test --AqNPlAX243a8sip3B7kXv8UKD8wuti-- """ proc = subprocess.run( - ["kibicara_mda", "hood"], stdout=subprocess.PIPE, input=mail, encoding='ascii' + ['kibicara_mda', 'hood'], stdout=subprocess.PIPE, input=mail, encoding='ascii' ) assert proc.returncode == 0 diff --git a/tests/tests_email/test_api_email_unauthorized.py b/tests/tests_email/test_api_email_unauthorized.py index ea0208b..4f22a37 100644 --- a/tests/tests_email/test_api_email_unauthorized.py +++ b/tests/tests_email/test_api_email_unauthorized.py @@ -18,6 +18,6 @@ def test_email_delete_unauthorized(client, hood_id, email_row): def test_email_message_unauthorized(client, hood_id, email_row): - body = {"text": "test", "author": "author", "secret": "wrong"} + body = {'text': 'test', 'author': 'author', 'secret': 'wrong'} response = client.post('/api/hoods/{0}/email/messages/'.format(hood_id), json=body) assert response.status_code == status.HTTP_401_UNAUTHORIZED diff --git a/tests/tests_email/test_api_email_wrong.py b/tests/tests_email/test_api_email_wrong.py index a3565c0..642b805 100644 --- a/tests/tests_email/test_api_email_wrong.py +++ b/tests/tests_email/test_api_email_wrong.py @@ -32,8 +32,8 @@ def test_email_subscribe_confirm_wrong_hood(client): def test_email_message_wrong(client, hood_id, email_row): body = { - 'text': "", - 'author': "test@localhost", + 'text': '', + 'author': 'test@localhost', 'secret': email_row['secret'], } response = client.post('/api/hoods/{0}/email/messages/'.format(hood_id), json=body)