Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/endpoints/csh_calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

This API interacts with the CSH Google calendar to pull the number of events set in the .env file to display in the calendar widget on Jumpstart


---

### Authentication
Expand Down
9 changes: 6 additions & 3 deletions src/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import httpx
import asyncio

from fastapi import APIRouter, Request, Form
from fastapi.responses import JSONResponse
Expand Down Expand Up @@ -64,9 +65,8 @@ async def slack_events(request: Request) -> JSONResponse:
"""

try:
logger.debug(f"Received Slack event: {await request.body()}")

body: dict = await request.json()
logger.debug(f"Received Slack event: {body}")

if request.headers.get("content-type") == "application/json":
if body.get("type") == "url_verification":
Expand All @@ -91,7 +91,10 @@ async def slack_events(request: Request) -> JSONResponse:
return JSONResponse({"status": "ignored"})

logger.info("SLACK EVENT: Requesting upload via dm!")
await slack.request_upload_via_dm(event.get("user", ""), cleaned_text)

await asyncio.create_task(
slack.request_upload_via_dm(event.get("user", ""), cleaned_text)
)
except Exception as e:
logger.error(f"Error handling Slack event: {e}")
return JSONResponse({"status": "error", "message": str(e)})
Expand Down
6 changes: 6 additions & 0 deletions src/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
--shadow-color: rgb(176,25,126, 0.5); /* Used for the shadow in the calendar */
}

/* b {
display: flex;
align-items: center;
justify-content: center;
} */

.theme-dark {
--panel-header-color: #B0197E;
--panel-header-text-color: #FFFFFF;
Expand Down
34 changes: 16 additions & 18 deletions tests/src/core/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

def import_slack_module(monkeypatch) -> object:
"""
Helper function to import the slack module after setting the SLACK_API_TOKEN environment variable.
Helper function to import the slack module after setting the SLACK_API_TOKEN environment variable.

Args:
monkeypatch: The pytest monkeypatch fixture.

Args:
monkeypatch: The pytest monkeypatch fixture.

Returns:
object: The imported config module.
Returns:
object: The imported config module.
"""

monkeypatch.setenv("SLACK_API_TOKEN", "test-token")
Expand Down Expand Up @@ -58,35 +58,33 @@ def test_get_username(monkeypatch):
"""
slack = import_slack_module(monkeypatch)

class FakeClient():
def __init__(self,display_name=None,real_name=None,name=None):
self.display_name:str | None = display_name
self.real_name:str | None = real_name
self.name:str | None = name
class FakeClient:
def __init__(self, display_name=None, real_name=None, name=None):
self.display_name: str | None = display_name
self.real_name: str | None = real_name
self.name: str | None = name

async def users_info(self, user):
return {
"ok": True,
"user": {
"profile":{
"display_name": self.display_name
},
"profile": {"display_name": self.display_name},
"real_name": self.real_name,
"name": self.name,
},
}

#Test Display Name
# Test Display Name
monkeypatch.setattr(slack, "client", FakeClient(display_name="DisplayName"))
username = asyncio.run(slack.get_username(user_id=""))
assert username == "DisplayName"

#Test Real Name
# Test Real Name
monkeypatch.setattr(slack, "client", FakeClient(real_name="RealName"))
username = asyncio.run(slack.get_username(user_id=""))
assert username == "RealName"

#Test Account Name
# Test Account Name
monkeypatch.setattr(slack, "client", FakeClient(name="AccountName"))
username = asyncio.run(slack.get_username(user_id=""))
assert username == "AccountName"
Expand All @@ -96,7 +94,7 @@ async def users_info(self, user):
username = asyncio.run(slack.get_username(user_id=""))
assert username == "Unknown"

# Test Failure

def test_gather_emojis_success_and_failure(monkeypatch):
"""
Test the gather_emojis function in the slack module.
Expand Down
Loading