Skip to content

Commit 562cbca

Browse files
PIG208timabbott
authored andcommitted
tools: Refactor ScreenshotConfig for non-webhook integrations.
1 parent 9ac55a8 commit 562cbca

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

zerver/lib/integrations.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,15 @@ def split_fixture_path(path: str) -> Tuple[str, str]:
233233

234234

235235
@dataclass
236-
class ScreenshotConfig:
236+
class BaseScreenshotConfig:
237237
fixture_name: str
238238
image_name: str = "001.png"
239239
image_dir: Optional[str] = None
240240
bot_name: Optional[str] = None
241+
242+
243+
@dataclass
244+
class ScreenshotConfig(BaseScreenshotConfig):
241245
payload_as_query_param: bool = False
242246
payload_param_name: str = "payload"
243247
extra_params: Dict[str, str] = field(default_factory=dict)
@@ -246,9 +250,12 @@ class ScreenshotConfig:
246250

247251

248252
def get_fixture_and_image_paths(
249-
integration: WebhookIntegration, screenshot_config: ScreenshotConfig
253+
integration: Integration, screenshot_config: BaseScreenshotConfig
250254
) -> Tuple[str, str]:
251-
fixture_dir = os.path.join("zerver", "webhooks", integration.name, "fixtures")
255+
if isinstance(integration, WebhookIntegration):
256+
fixture_dir = os.path.join("zerver", "webhooks", integration.name, "fixtures")
257+
else:
258+
fixture_dir = os.path.join("zerver", "integration_fixtures", integration.name)
252259
fixture_path = os.path.join(fixture_dir, screenshot_config.fixture_name)
253260
image_dir = screenshot_config.image_dir or integration.name
254261
image_name = screenshot_config.image_name
@@ -658,7 +665,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:
658665
}
659666

660667

661-
DOC_SCREENSHOT_CONFIG: Dict[str, List[ScreenshotConfig]] = {
668+
DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = {
662669
"airbrake": [ScreenshotConfig("error_message.json")],
663670
"alertmanager": [
664671
ScreenshotConfig("alert.json", extra_params={"name": "topic", "desc": "description"})

0 commit comments

Comments
 (0)