Test and refactors.

This commit is contained in:
Pablo Martin 2023-01-09 13:38:49 +01:00
parent f684b2a043
commit 8534c727c4
4 changed files with 70 additions and 12 deletions

35
tests/test_lolaconfig.py Normal file
View file

@ -0,0 +1,35 @@
from types import SimpleNamespace
from lolafect.lolaconfig import LolaConfig
def test_lolaconfig_instantiates_with_defaults_properly():
lolaconfig = LolaConfig(flow_name="some-flow")
def test_lolaconfig_instantiates_without_defaults_proplery():
lolaconfig = LolaConfig(
flow_name="some-flow",
env_s3_bucket="bucket",
kubernetes_labels=["some_label"],
kubernetes_image="loliloli:latest",
slack_webhooks_file="the_file/is/here.json",
)
def test_lolaconfig_fetches_webhooks_properly():
lolaconfig = LolaConfig(flow_name="some-flow")
fake_s3_reader = SimpleNamespace()
def mock_read_json_from_s3_file(bucket, key):
return {"a-channel-name": "a-channel-url.com"}
fake_s3_reader.read_json_from_s3_file = mock_read_json_from_s3_file
lolaconfig.fetch_slack_webhooks(s3_reader=fake_s3_reader)
assert type(lolaconfig.SLACK_WEBHOOKS) is dict