-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_config.py
More file actions
32 lines (23 loc) · 989 Bytes
/
test_config.py
File metadata and controls
32 lines (23 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Tests for ``paperscout.config`` validation."""
from __future__ import annotations
import pytest
from paperscout.config import Settings
from paperscout.errors import ConfigurationError
def test_settings_rejects_blank_slack_when_not_testing(monkeypatch):
monkeypatch.delenv("_PAPERSCOUT_TESTING", raising=False)
with pytest.raises(ConfigurationError, match="Slack is not configured"):
Settings(
slack_bot_token="",
slack_signing_secret="",
)
def test_settings_accepts_slack_when_not_testing(monkeypatch):
monkeypatch.delenv("_PAPERSCOUT_TESTING", raising=False)
s = Settings(
slack_bot_token="xoxb-real",
slack_signing_secret="not-empty",
)
assert s.slack_bot_token == "xoxb-real"
def test_settings_allows_empty_slack_under_testing_flag(monkeypatch):
monkeypatch.setenv("_PAPERSCOUT_TESTING", "1")
s = Settings(slack_bot_token="", slack_signing_secret="")
assert s.slack_bot_token == ""