mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
tools: Add script to trigger webhook notification using fixtures.
When creating a webhook integration or creating a new one, it is a pain to create or update the screenshots in the documentation. This commit adds a tool that can trigger a sample notification for the webhook using a fixture, that is likely already written for the tests. Currently, the developer needs to take a screenshot manually, but this could be automated using puppeteer or something like that. Also, the tool does not support webhooks with basic auth, and only supports webhooks that use json fixtures. These can be fixed in subsequent commits.
This commit is contained in:
committed by
Tim Abbott
parent
4c142b778a
commit
4d2ce607c9
@@ -4,7 +4,10 @@ import glob
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from typing import List
|
||||
import tempfile
|
||||
from typing import List, Optional
|
||||
|
||||
import cairosvg
|
||||
|
||||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
if ZULIP_PATH not in sys.path:
|
||||
@@ -42,5 +45,13 @@ def generate_zulip_bots_static_files() -> None:
|
||||
docs = glob.glob(doc_glob_pattern)
|
||||
copyfiles(docs)
|
||||
|
||||
def create_png_from_svg(svg_path: str, destination_dir: Optional[str]=None) -> str:
|
||||
png_name = os.path.splitext(os.path.basename(svg_path))[0] + '.png'
|
||||
if destination_dir is None:
|
||||
destination_dir = tempfile.gettempdir()
|
||||
png_path = os.path.join(destination_dir, png_name)
|
||||
cairosvg.svg2png(url=svg_path, write_to=png_path)
|
||||
return png_path
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_zulip_bots_static_files()
|
||||
|
||||
Reference in New Issue
Block a user