Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
lint; update validators
Browse files Browse the repository at this point in the history
  • Loading branch information
aplybeah committed Jul 8, 2024
1 parent 0946598 commit 7d9a5da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ def show_and_or_post_results(
"""Optionally show the results of a metric and/or post them to slack."""
# defer load of settings until this command is called
# this prevents an error if ANALYTICS_SLACK_BOT_TOKEN env var is unset
from config import DBSettings as settings
from config import DBSettings

# optionally display the burndown chart in the browser
if show_results:
metric.show_chart()
print("Slack message:\n")
print(metric.format_slack_message())
if post_results:
slackbot = slack.SlackBot(client=WebClient(token=settings.slack_bot_token))
slackbot = slack.SlackBot(client=WebClient(token=DBSettings.slack_bot_token))
metric.post_results_to_slack(
slackbot=slackbot,
channel_id=settings.reporting_channel_id,
channel_id=DBSettings.reporting_channel_id,
output_dir=Path(output_dir),
)
5 changes: 3 additions & 2 deletions analytics/src/analytics/integrations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

from config import DBSettings

# The variables used in the connection url are pulled from local.env
# and configured in the DBSettings class found in config.py

# The variables used in the connection url are pulled from local.env and configured in the DBSettings class found in config.py

def get_db() -> Engine:
"""
Expand All @@ -20,7 +21,7 @@ def get_db() -> Engine:
sqlalchemy.engine.Engine
A SQLAlchemy engine object representing the connection to the database.
"""
db = DBSettings()
db = DBSettings
print(f"postgresql+psycopg://{db.user}:{db.password}@{db.db_host}:{db.port}")
return create_engine(
f"postgresql+psycopg://{db.user}:{db.password}@{db.db_host}:{db.port}",
Expand Down
10 changes: 6 additions & 4 deletions analytics/tests/integrations/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from slack_sdk import WebClient

from analytics.integrations.slack import FileMapping, SlackBot
from config import DBSettings as settings
from config import DBSettings

client = WebClient(token=settings.slack_bot_token)
client = WebClient(token=DBSettings.slack_bot_token)


@pytest.fixture(name="slackbot")
Expand All @@ -19,7 +19,9 @@ def mock_slackbot() -> SlackBot:
@pytest.mark.skip(reason="requires Slack token")
def test_fetch_slack_channels(slackbot: SlackBot):
"""The fetch_slack_channels() function should execute correctly."""
result = slackbot.fetch_slack_channel_info(channel_id=settings.reporting_channel_id)
result = slackbot.fetch_slack_channel_info(
channel_id=DBSettings.reporting_channel_id,
)
assert result["ok"] is True
assert result["channel"]["name"] == "z_bot-analytics-ci-test"

Expand Down Expand Up @@ -47,7 +49,7 @@ def test_upload_files_to_slack_channel(slackbot: SlackBot):
"""
result = slackbot.upload_files_to_slack_channel(
files=files,
channel_id=settings.reporting_channel_id,
channel_id=DBSettings.reporting_channel_id,
message=markdown,
)
assert result["ok"] is True
Expand Down

0 comments on commit 7d9a5da

Please sign in to comment.