diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f0e15eb..1ee6b87 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -29,18 +29,16 @@ jobs: - name: Publish uses: pypa/gh-action-pypi-publish@v1.8.11 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 - < 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 diff --git a/tests/test_format_message.py b/tests/test_format_message.py new file mode 100644 index 0000000..1d0cd15 --- /dev/null +++ b/tests/test_format_message.py @@ -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 diff --git a/tests/test_hello_world.py b/tests/test_hello_world.py deleted file mode 100644 index b6e7bb3..0000000 --- a/tests/test_hello_world.py +++ /dev/null @@ -1,3 +0,0 @@ - -def test_hello_world(): - print("hello world") \ No newline at end of file