HassamGani commited on
Commit ·
d201d08
1
Parent(s): 25de09c
Count any reply naming the figure as a fresh notice after a relax
Browse files- reorgbench/gen/build.py +4 -4
- reorgbench/gen/units.py +1 -13
- tests/test_generator.py +0 -10
reorgbench/gen/build.py
CHANGED
|
@@ -22,7 +22,7 @@ from ..tasks.spec import (
|
|
| 22 |
Trigger,
|
| 23 |
)
|
| 24 |
from .units import (
|
| 25 |
-
Ask, Close, Code, Credit, Move, Notify, Refund, Unit, credits_by, current_says, is_retraction, refunds_on, replies, says,
|
| 26 |
rerun_tests, told_and_not_retracted,
|
| 27 |
)
|
| 28 |
from .world import Acct, Ids
|
|
@@ -349,13 +349,13 @@ def checkpoints(g: Gen, cancel_id: str | None, modify_id: str | None) -> list[Ch
|
|
| 349 |
return False
|
| 350 |
if c not in back:
|
| 351 |
return True
|
| 352 |
-
# brought back after a cancel:
|
| 353 |
eid = v.fired_event(relax_id)
|
| 354 |
if eid is None:
|
| 355 |
return False
|
| 356 |
posts = texts[sum(1 for r in reply_events(v) if r["ticket_id"] == tk and r["event"] < eid):]
|
| 357 |
-
fresh = [i for i, t in enumerate(posts) if
|
| 358 |
-
return bool(fresh) and not any(is_retraction(t)
|
| 359 |
out.append(Checkpoint(n.ck, "each customer in scope told on their ticket, with the current figure",
|
| 360 |
lambda w, v: all(told(w, v, c) for c in scope),
|
| 361 |
capability="support", realized_by=lambda w: [f"tickets/{acc[c].ticket}" for c in scope]))
|
|
|
|
| 22 |
Trigger,
|
| 23 |
)
|
| 24 |
from .units import (
|
| 25 |
+
Ask, Close, Code, Credit, Move, Notify, Refund, Unit, credits_by, current_says, is_retraction, refunds_on, replies, says,
|
| 26 |
rerun_tests, told_and_not_retracted,
|
| 27 |
)
|
| 28 |
from .world import Acct, Ids
|
|
|
|
| 349 |
return False
|
| 350 |
if c not in back:
|
| 351 |
return True
|
| 352 |
+
# brought back after a cancel: told the figure again since then, and not taken back after that
|
| 353 |
eid = v.fired_event(relax_id)
|
| 354 |
if eid is None:
|
| 355 |
return False
|
| 356 |
posts = texts[sum(1 for r in reply_events(v) if r["ticket_id"] == tk and r["event"] < eid):]
|
| 357 |
+
fresh = [i for i, t in enumerate(posts) if says(t, val)]
|
| 358 |
+
return bool(fresh) and not any(is_retraction(t) for t in posts[fresh[-1] + 1:])
|
| 359 |
out.append(Checkpoint(n.ck, "each customer in scope told on their ticket, with the current figure",
|
| 360 |
lambda w, v: all(told(w, v, c) for c in scope),
|
| 361 |
capability="support", realized_by=lambda w: [f"tickets/{acc[c].ticket}" for c in scope]))
|
reorgbench/gen/units.py
CHANGED
|
@@ -163,22 +163,10 @@ _RETRACT = re.compile(
|
|
| 163 |
r"has(n'?t| not) changed|stay(s|ing)? (on|in|with)|remain(s|ing)? (on|in|with)|continue(s)? (on|in|with)", re.I)
|
| 164 |
|
| 165 |
|
| 166 |
-
# says the customer is staying put, as opposed to only taking back an earlier message ("disregard our last note:
|
| 167 |
-
# your move is going ahead")
|
| 168 |
-
_STAYS = re.compile(r"stay(s|ing)? (on|in|with)|remain(s|ing)? (on|in|with)|continue(s)? (on|in|with)|unchanged|"
|
| 169 |
-
r"postpone|on hold|no longer appl|not part of|separately|(not|n't) (be |been |being )?(moved|moving|"
|
| 170 |
-
r"migrated|migrating|changed|changing|switched|switching|included|affected)|(won'?t|will not) be "
|
| 171 |
-
r"(moved|moving|migrated|migrating|changed|changing|switched|switching)", re.I)
|
| 172 |
-
|
| 173 |
-
|
| 174 |
def is_retraction(text: str) -> bool:
|
| 175 |
return bool(_RETRACT.search(text))
|
| 176 |
|
| 177 |
|
| 178 |
-
def is_fresh_notice(text: str, value: Any) -> bool:
|
| 179 |
-
"""States the value without saying the customer stays put."""
|
| 180 |
-
return says(text, value) and not _STAYS.search(text)
|
| 181 |
-
|
| 182 |
|
| 183 |
def told_and_not_retracted(texts: list[str]) -> bool:
|
| 184 |
told = [i for i, t in enumerate(texts) if not is_retraction(t)]
|
|
@@ -186,4 +174,4 @@ def told_and_not_retracted(texts: list[str]) -> bool:
|
|
| 186 |
|
| 187 |
|
| 188 |
__all__ = ["Unit", "Move", "Notify", "Credit", "Refund", "Close", "Code", "Ask", "says", "current_says", "money",
|
| 189 |
-
"credits_by", "refunds_on", "rerun_tests", "is_retraction", "
|
|
|
|
| 163 |
r"has(n'?t| not) changed|stay(s|ing)? (on|in|with)|remain(s|ing)? (on|in|with)|continue(s)? (on|in|with)", re.I)
|
| 164 |
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
def is_retraction(text: str) -> bool:
|
| 167 |
return bool(_RETRACT.search(text))
|
| 168 |
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
def told_and_not_retracted(texts: list[str]) -> bool:
|
| 172 |
told = [i for i, t in enumerate(texts) if not is_retraction(t)]
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
__all__ = ["Unit", "Move", "Notify", "Credit", "Refund", "Close", "Code", "Ask", "says", "current_says", "money",
|
| 177 |
+
"credits_by", "refunds_on", "rerun_tests", "is_retraction", "told_and_not_retracted", "replies"]
|
tests/test_generator.py
CHANGED
|
@@ -148,13 +148,3 @@ def test_big_listings_page_instead_of_being_cut():
|
|
| 148 |
seen += r[key]
|
| 149 |
off = r.get("next_offset")
|
| 150 |
assert len(seen) == r["total"] > 40
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
@pytest.mark.parametrize("text,fresh", [
|
| 154 |
-
("Update: please disregard our last message. Your move is going ahead in MW-6246.", True),
|
| 155 |
-
("Your account will move after all. Your window is MW-6246.", True),
|
| 156 |
-
("Please disregard our message about MW-6246. Your account is staying in eu-west-1.", False),
|
| 157 |
-
])
|
| 158 |
-
def test_fresh_notice_after_a_relax(text, fresh):
|
| 159 |
-
from reorgbench.gen.units import is_fresh_notice
|
| 160 |
-
assert is_fresh_notice(text, "MW-6246") is fresh
|
|
|
|
| 148 |
seen += r[key]
|
| 149 |
off = r.get("next_offset")
|
| 150 |
assert len(seen) == r["total"] > 40
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|