diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2024-01-05 17:31:35 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | f90dad098b591a4c2e55ede3af6526c007de6229 (patch) | |
tree | 66e9145de0ac74a6cf7d3c948d2eb628e58f5fb2 /tests | |
parent | a8fa7a1bc08d326dea3fde8a3b6437c684b9fac5 (diff) | |
download | wee-slack-f90dad098b591a4c2e55ede3af6526c007de6229.tar.gz |
Make URL format configurable
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 12 | ||||
-rw-r--r-- | tests/test_render_blocks.py | 6 |
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 891dc67..981faab 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -116,6 +116,17 @@ def info_get(info_name: str, arguments: str): return "" +def string_eval_expression( + expr: str, + pointers: Dict[str, str], + extra_vars: Dict[str, str], + options: Dict[str, str], +) -> str: + for key, value in extra_vars.items(): + expr = expr.replace(f"${{{key}}}", value) + return expr + + weechat.config_new_option = config_new_option weechat.config_option_set = config_option_set weechat.config_boolean = config_boolean @@ -124,6 +135,7 @@ weechat.config_string = config_string weechat.config_color = config_color weechat.color = color weechat.info_get = info_get +weechat.string_eval_expression = string_eval_expression shared.weechat_version = 0x03080000 shared.weechat_callbacks = {} diff --git a/tests/test_render_blocks.py b/tests/test_render_blocks.py index 6b1fc0f..63e4df5 100644 --- a/tests/test_render_blocks.py +++ b/tests/test_render_blocks.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List import pytest +from slack.shared import shared from slack.slack_message import SlackMessage from tests.conftest import ( color_reset, @@ -128,7 +129,7 @@ cases: List[Case] = [ "normal <[color:bold]>*bold*<[color:-bold]> <[color:italic]>_italic_" "<[color:-italic]> ~strikethrough~ <[color:bold]><[color:italic]>" "*_~bold-italic-strikethrough~_*<[color:-italic]><[color:-bold]> " - "https://vg.no (link)", + "link (https://vg.no)", "1. number", "2. list", "> some quote", @@ -447,7 +448,8 @@ cases: List[Case] = [ @pytest.mark.parametrize("case", cases) -def test_unfurl_refs(case: Case, message1_in_channel_public: SlackMessage): +def test_render_blocks(case: Case, message1_in_channel_public: SlackMessage): + shared.config.look.render_url_as.value = "${text} (${url})" parsed = message1_in_channel_public._render_blocks( # pyright: ignore [reportPrivateUsage] case["blocks"] ) |