Skip to content

Commit

Permalink
Fixing format (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled authored Oct 3, 2024
2 parents 7d37d32 + ab3c963 commit fc08eff
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
13 changes: 9 additions & 4 deletions core/migrations/0006_notificationconfig_and_more.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Generated by Django 4.2.3 on 2023-09-14 12:39

import core.models
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models

import core.models


class Migration(migrations.Migration):

dependencies = [
("core", "0005_rename_message_ts_notificationstatus_message_timestamp"),
(
"core",
"0005_rename_message_ts_notificationstatus_message_timestamp",
),
]

operations = [
Expand Down Expand Up @@ -58,7 +62,8 @@ class Migration(migrations.Migration):
model_name="notificationstatus",
name="status",
field=models.CharField(
choices=[("success", "Success"), ("error", "Error")], max_length=7
choices=[("success", "Success"), ("error", "Error")],
max_length=7,
),
),
migrations.AlterField(
Expand Down
2 changes: 2 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from django.db import models
from django.utils import timezone


class DateTimeWithoutTZField(models.DateTimeField):
def db_type(self, connection):
return "timestamp"


class NotificationFilters(models.TextChoices):
AUTHOR = "author"
BRANCH = "branch"
Expand Down
9 changes: 4 additions & 5 deletions core/slack_datastores.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def save(self, installation: Installation):
if is_naive(user_token_expires_at):
user_token_expires_at = make_aware(user_token_expires_at)

# can have one installation per team id
# can have one installation per team id
slack_installation = SlackInstallation.objects.filter(
team_id=installation.team_id,
).first()

if slack_installation is None:
slack_installation = SlackInstallation()

Expand Down Expand Up @@ -94,15 +94,14 @@ def save(self, installation: Installation):
)
slack_installation.token_type = installation.token_type
slack_installation.installed_at = installed_at

try:
slack_installation.save()
self.save_bot(installation.to_bot())

except Exception as e:
self._logger.error(f"Error saving installation: {e}")


def save_bot(self, bot: Bot):
installed_at = bot.installed_at
bot_token_expires_at = bot.bot_token_expires_at
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def test_file_coverage_report_resolver_count_is_zero(


def test_help_resolver():
client=MagicMock()
client = MagicMock()

resolve_help(
channel_id="random_channel_id",
Expand Down
4 changes: 3 additions & 1 deletion service_auth/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def view_login_modal(
slack_user_id = command["user_id"]
channel_id = command["channel_id"]
slack_state_jwt = jwt.encode(
{"user_id": slack_user_id, "channel_id": channel_id}, USER_ID_SECRET, algorithm="HS256"
{"user_id": slack_user_id, "channel_id": channel_id},
USER_ID_SECRET,
algorithm="HS256",
)

# create slack user
Expand Down
2 changes: 1 addition & 1 deletion service_auth/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
os.environ["SLACK_CLIENT_ID"] = "292929292929.292929292929"
os.environ["SLACK_CLIENT_SECRET"] = "random_client_secret"
os.environ["SLACK_APP_ID"] = "292929292929"
os.environ["CODECOV_API"] = "https://codecov.io/api"
os.environ["CODECOV_API"] = "https://codecov.io/api"
4 changes: 3 additions & 1 deletion service_auth/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def test_missing_slack_user(self, mock_post, mock_get):
)

assert response.status_code == 404
assert response.json() == {"detail": "Slack user not found random_test_id"}
assert response.json() == {
"detail": "Slack user not found random_test_id"
}

@patch("requests.get")
@patch("requests.post")
Expand Down
12 changes: 6 additions & 6 deletions service_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def get(self, request, format=None):
state = request.GET.get("state")
validate_gh_call_params(code, state)

user_id = jwt.decode(
state, USER_ID_SECRET, algorithms=["HS256"]
)["user_id"]
user_id = jwt.decode(state, USER_ID_SECRET, algorithms=["HS256"])[
"user_id"
]

channel_id = jwt.decode(
state, USER_ID_SECRET, algorithms=["HS256"]
)["channel_id"]
channel_id = jwt.decode(state, USER_ID_SECRET, algorithms=["HS256"])[
"channel_id"
]

# Exchange the authorization code for an access token
headers = {"Accept": "application/json"}
Expand Down

0 comments on commit fc08eff

Please sign in to comment.