-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_service.py
More file actions
50 lines (38 loc) · 1.87 KB
/
Copy pathtest_service.py
File metadata and controls
50 lines (38 loc) · 1.87 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations
from app.service import conservative_cleanup
from app.text_styles import apply_writing_style
CASUAL_STYLE = "casual"
def test_cleanup_is_conservative() -> None:
assert conservative_cleanup(" hello world ") == "hello world."
assert conservative_cleanup("Already done!") == "Already done!"
assert conservative_cleanup("space before , punctuation") == "space before, punctuation."
def test_formal_style_capitalizes_and_adds_aa() -> None:
assert (
apply_writing_style(" hello world , how are you ", "formal")
== "Hello world, how are you."
)
def test_casual_style_drops_only_the_closin_f3c53() -> None:
"""Commas used to be stripped wholesale, which corrupted prices and lists.
Casual now differs from formal by running sentences together instead."""
assert (
apply_writing_style("hello, world; this is relaxed.", CASUAL_STYLE)
== "Hello, world; this is relaxed"
)
assert apply_writing_style("are we ready?", CASUAL_STYLE) == "Are we ready?"
assert (
apply_writing_style("visit https://example.com, please.", CASUAL_STYLE)
== "Visit https://example.com, please"
)
assert apply_writing_style("Hello there. It is fine.", CASUAL_STYLE) == (
"Hello there. It is fine"
)
def test_very_casual_style_lowercases_witho_e1bef() -> None:
"""Stripping every punctuation mark turned "Don't" into "dont" and broke
decimals, times and addresses. Only the casing is casual now."""
assert (
apply_writing_style("Hello, WORLD! Don't stop—now.", "very_casual")
== "hello, world! don't stop—now"
)
def test_excited_style_exclaims_every_statement() -> None:
assert apply_writing_style("we did it. this works", "excited") == "We did it! This works!"
assert apply_writing_style("ask Dr. Smith", "excited") == "Ask Dr. Smith!"