-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_quotes.py
66 lines (52 loc) · 2.7 KB
/
test_quotes.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from typing import Tuple
import pytest
from marian_client.quote_manager import Quotes
smart_quotes = [
"We’ve sent you a couple of emails, but we haven’t heard back.",
"Yeah, he’d’ve done something ʻsmartʼ I guess.",
"One of these customers calls in, saying, ‘I’m upset about a bad Yelp review I got and also I don’t understand how this part of my ads program is working.’",
"You get another phone call and it’s a business that says something.",
"They say, ‘Hey, I’d like to actually grow my business more and I’d like to spend more money.’",
]
change_words_not_quotes = [
"We've sent you a couple of emails, but we haven't heard back.",
"Yeah, she'll've said something 'intelligent' I suppose.",
"A customers calls in and says, 'I'm not happy with a Yelp review I got and also I don't understand how this part of my ads program is working.'",
"You get a second phone call and it's a company that says something.",
"They say, 'I'd like to grow my business and I'd like to spend more money.'",
]
requoted = [
"We’ve sent you a couple of emails, but we haven’t heard back.",
"Yeah, she’ll’ve said something ʻintelligentʼ I suppose.",
"A customers calls in and says, ‘I’m not happy with a Yelp review I got and also I don’t understand how this part of my ads program is working.’",
"You get a second phone call and it’s a company that says something.",
"They say, ‘I’d like to grow my business and I’d like to spend more money.’",
]
@pytest.mark.parametrize("text", smart_quotes)
def test_requote_no_change(text: str):
q = Quotes(text)
assert q.requote_modified_string(q.simplified) == q.orig
@pytest.mark.parametrize(
"before_after_correct", list(zip(smart_quotes, change_words_not_quotes, requoted))
)
def test_text_change_but_same_quote_count(before_after_correct: Tuple[str, str, str]):
before, after, correct = before_after_correct
q = Quotes(before)
assert q.requote_modified_string(after) == correct
changed_quote_cases = [
(
"Yeah , he’d’ve done something “intelligent”",
'Yeah , he\'s done something "intelligent"',
"Yeah , he’s done something “intelligent”",
),
(
"There are many storeʼs like that one , which Iʼm a fan of",
"There are many stores like that one , which I'm a fan of",
"There are many stores like that one , which Iʼm a fan of",
),
]
@pytest.mark.parametrize("before_after_correct", changed_quote_cases)
def test_change_quote_count(before_after_correct: Tuple[str, str, str]):
before, after, correct = before_after_correct
q = Quotes(before)
assert q.requote_modified_string(after) == correct