Skip to content

Commit

Permalink
fix: requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
cyber-francis committed Jan 2, 2024
1 parent 3153523 commit 727873d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ jobs:
- name: Publish
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
# repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Test Install
run: |
python3 -m pip install --no-cache-dir -i https://test.pypi.org/simple/ slack-notification
python3 -m pip install --no-cache-dir slack-notification
- name: Test Usage
run: |
python3 - <<EOF
from slack_notification.slack_notification import SlackNotification
APP_NAME = "APP_X"
APP_VERSION = "v0.0.1"
EOF
6 changes: 5 additions & 1 deletion src/slack_notification/slack_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ def __init__(self, channel, timeout=10) -> None:
self._timeout = timeout

def notify(self, message):
message = {"text": str(message)}
message = self.format(message)
response = requests.post(
self._webhook, json.dumps(message).encode("utf-8"), timeout=self._timeout
)
return response

def format(self, message):
message = {"text": str(message)}
return message
14 changes: 14 additions & 0 deletions tests/test_format_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from src.slack_notification.slack_notification import SlackNotification


def test_format_str():
slack = SlackNotification("FAKE_CHANNEL")
formated_message = slack.format("TEST_MESSAGE")
assert formated_message == {"text": "TEST_MESSAGE"}


def test_format_dict():
slack = SlackNotification("FAKE_CHANNEL")
formated_message = slack.format({"KEY": "VALUE"})
assert formated_message == {"text": "{'KEY': 'VALUE'}"}
formated_message = slack.format
3 changes: 0 additions & 3 deletions tests/test_hello_world.py

This file was deleted.

0 comments on commit 727873d

Please sign in to comment.