1
from broadcast import Broadcast, BroadcastError, kickoff_for, render2
from mapping import Work3
4
FULL = """*North Star launch*5
`north-star` · active6
7
Jordan Lee owns it8
Ada Chen is on it9
10
> Default to the single, then the pair, then the set.11
> — Jordan Lee12
13
Reply in this thread. One status is enough.14
"""15
16
17
def test_kickoff_is_a_card_not_a_dump():18
text = render(19
Broadcast(20
kind="kickoff",21
work_id="north-star",22
title="North Star launch",23
state="active",24
owner="Jordan Lee",25
assignee="Ada Chen",26
quote="Default to the single, then the pair, then the set.",27
quote_from="Jordan Lee",28
)29
)30
assert text == FULL31
for banned in ("broadcast:", "state:", "owner:", "in flight:", "context:"):32
assert banned not in text33
34
35
def test_empty_fields_are_omitted():36
text = render(37
Broadcast(38
kind="nudge",39
work_id="beta-waitlist",40
title="Beta waitlist",41
state="active",42
)43
)44
assert "owns it" not in text45
assert "is on it" not in text46
assert ">" not in text47
assert text.endswith("Still open. Reply in this thread.\n")48
49
50
def test_discord_bolds_with_two_stars():51
text = render(52
Broadcast(53
kind="done",54
work_id="north-star",55
title="North Star launch",56
state="closed",57
platform="discord",58
)59
)60
assert text.startswith("**North Star launch**\n")61
assert text.endswith("Closed.\n")62
63
64
def test_kind_must_match_state():65
try:66
render(67
Broadcast(68
kind="kickoff",69
work_id="north-star",70
title="North Star launch",71
state="blocked",72
)73
)74
raise AssertionError("kickoff accepted a blocked row")75
except BroadcastError:76
pass77
78
79
def test_kickoff_for_uses_the_work_row():80
w = Work(81
id="north-star",82
name="North Star launch",83
room="C0OPS03",84
state="active",85
anchor="",86
owner="Jordan Lee",87
)88
text = kickoff_for(w, assignee="Ada Chen")89
assert "Jordan Lee owns it" in text90
assert "Ada Chen is on it" in text91
assert text.startswith("*North Star launch*\n")92
93
94
if __name__ == "__main__":95
test_kickoff_is_a_card_not_a_dump()96
test_empty_fields_are_omitted()97
test_discord_bolds_with_two_stars()98
test_kind_must_match_state()99
test_kickoff_for_uses_the_work_row()100
print("ok")101