Item 6: sisi learn prints the stored text, id, scope and the withdraw command. done 6 / next 7 (brief template)
This commit is contained in:
1 parent
4061733430
commit
1b57d00e60
2 files changed
+19
-2
No files matched your search
+4
-2
@@ -65,6 +65,8 @@ def cmd_learn(argv):
|
|||||||
os.getcwd(), L.unit_id(), change=statement, mechanism="knowledge",
|
os.getcwd(), L.unit_id(), change=statement, mechanism="knowledge",
|
||||||
scope=scope, expect="the agent acts on this statement",
|
scope=scope, expect="the agent acts on this statement",
|
||||||
owner_statement=True, entered_via="learn", origin=origin)
|
owner_statement=True, entered_via="learn", origin=origin)
|
||||||
print("recorded owner statement %s (%s; printed by `sisi oracle`; withdraw a mistake with "
|
print("recorded owner statement %s (%s)" % (rec["id"], origin))
|
||||||
"`sisi learn --withdraw %s --reason ...`)" % (rec["id"], origin, rec["id"]))
|
print(" stored: %s" % rec["observation"]["evidence"])
|
||||||
|
print(" scope: %s; it takes effect at once and `sisi oracle` prints it" % rec["proposed"]["scope"])
|
||||||
|
print(" to take it back: sisi learn --withdraw %s --reason \"<why it was recorded by mistake>\"" % rec["id"])
|
||||||
return 0
|
return 0
|
||||||
@@ -936,6 +936,21 @@ class Store(Base):
|
|||||||
self.assertIn("prefer short plain reports", r.stdout)
|
self.assertIn("prefer short plain reports", r.stdout)
|
||||||
self.assertEqual(len(L.owner_statements()), 1)
|
self.assertEqual(len(L.owner_statements()), 1)
|
||||||
|
|
||||||
|
def test_learn_says_what_it_stored_and_how_to_take_it_back(self):
|
||||||
|
"""R-12-1: the receipt shows the stored text (secrets scrubbed), id, scope and a withdraw command that works."""
|
||||||
|
out = self.sisi("learn", "--scope", "project", "prefer short plain reports, password=hunter2hunter2").stdout
|
||||||
|
row = self.rows()[0]
|
||||||
|
self.assertIn(row["id"], out)
|
||||||
|
self.assertIn("scope: project", out)
|
||||||
|
self.assertIn(row["observation"]["evidence"], out)
|
||||||
|
self.assertNotIn("hunter2", out)
|
||||||
|
cmd = [l for l in out.splitlines() if "sisi learn --withdraw" in l][0].split("sisi learn ", 1)[1]
|
||||||
|
self.assertIn("--withdraw %s " % row["id"], cmd)
|
||||||
|
import shlex
|
||||||
|
r = self.sisi("learn", *shlex.split(cmd.replace("<why it was recorded by mistake>", "test")))
|
||||||
|
self.assertEqual(r.returncode, 0, r.stderr)
|
||||||
|
self.assertEqual(L.owner_statements(), [])
|
||||||
|
|
||||||
def test_learn_records_whether_the_owner_typed_it(self):
|
def test_learn_records_whether_the_owner_typed_it(self):
|
||||||
"""A statement quoted from a human-typed message of the session transcript is `typed by the
|
"""A statement quoted from a human-typed message of the session transcript is `typed by the
|
||||||
owner`; a relayed one, or none to check, is `relayed by an agent`. Never blocked."""
|
owner`; a relayed one, or none to check, is `relayed by an agent`. Never blocked."""
|
||||||
|
|||||||
Reference in new issue
Block a user