def test_simple_interaction(tracker, reftype): tracker.deserialize({"life": u"task: target\n" u"days\n" u" day: today\n" u" @started\n" u" %s: << > target\n" u" @active\n" % reftype }) navigation._cmd("createauto", tracker.root, u"task: test") active_node = tracker.root.active_node proxy = tracker.root.find(u"days > today > " + reftype + u" > test").one() target = tracker.root.find(u"target > test").one() assert active_node is proxy assert proxy is not target assert proxy._px_target is target assert proxy._px_root.get_proxy(target) is proxy navigation._cmd("createfinish", tracker.root, u"-> task: test 2") target = tracker.root.find(u"target").one() assert target.started first_child = target.children.next_neighbor assert first_child.started assert first_child.finished second_child = first_child.next_neighbor assert second_child.started assert not second_child.finished proxy_active = tracker.root.find(u"days > day > " + reftype + u"> test 2").one() assert proxy_active is tracker.root.active_node
def test_another_interaction(tracker, reftype): tracker.deserialize({"life": u"task: target\n" u"days\n" u" day: today\n" u" @started\n" u" %s: << > target\n" u" @active\n" % reftype }) navigation._cmd("createauto", tracker.root, u"task: test 1") navigation._cmd("createfinish", tracker.root, u"< > +task: test 2") target = tracker.root.find(u"target").one() assert target.started first_child = target.children.next_neighbor assert first_child.started assert first_child.finished second_child = first_child.next_neighbor assert second_child.started assert not second_child.finished proxy_active = tracker.root.find(u"days > day > " + reftype + u" > test 2").one() assert proxy_active is tracker.root.active_node
def test_activate_deactivate(monkeypatch, setdt): setdt(2012, 10, 24) tracker = Tracker(nodecreator=FakeNodeCreator(tasks.Task), skeleton=False) tracker.deserialize({"life": "task: \xfc1\n" " @active\n" "task: \xfc2\n" "task: \xfc3\n" }) setdt(2012, 10, 24, 0, 5) navigation._cmd("done", tracker.root) navigation._cmd("done", tracker.root) assert match(tracker.serialize()["life"], ( "task#?????: \xfc1\n" " @finished: 5m after October 24, 2012 12:00:00 AM\n" "task#?????: \xfc2\n" " @finished: 0s after October 24, 2012 12:05:00 AM\n" "task#?????: \xfc3\n" " @started: October 24, 2012 12:05:00 AM\n" " @active\n" ))
def test_unfinish_targetfinished(self, tracker, reftype): tracker.deserialize({"life": u"task#abcde: \xfctarget 1\n" u" @started\n" u" @finished\n" u" task: \xfctarget 2\n" u"days\n" u" day: today\n" u" @active\n" u" {}: << >\n" u" @started\n" u" @finished\n".format(reftype) }) refnode = tracker.root.find(u"** > " + reftype).one() assert refnode.finished assert _dump([refnode]) == [ reftype + u": " + refnode.text ] assert tracker.root.active_node.node_type == u"day" target = tracker.root.find(u"task: \xfctarget 1").one() assert target.finished navigation._cmd("forceactivate", tracker.root, u">") assert tracker.root.active_node is refnode assert refnode.started assert not refnode.finished assert not refnode._px_target.finished assert _dump([refnode]) == [ reftype + u": #abcde", u" proxy: task: \xfctarget 2" ]
def test_next_empty(self): tracker = Tracker(skeleton=False) node = GenericActivate("herp", None, tracker.root) tracker.root.addchild(node) tracker.root.activate(node) navigation._cmd("done", tracker.root) assert tracker.root.active_node is tracker.root
def test_activate(self, tracker, reftype, setdt): setdt(2014, 1, 1, 1, 1) tracker.deserialize({"life": u"task: \xfctarget 1\n" u" task: \xfctarget 2\n" u" task: \xfctarget 3\n" u"%s: <-\n" u"days\n" u" day: today\n" u" reference: << > %s\n" u" @active\n" % (reftype, reftype) }) root = tracker.root # manual search just in case days = tracker.root.children.prev_neighbor day = days.children.next_neighbor ref = day.children.prev_neighbor assert root.active_node is ref setdt.increment(seconds=1) navigation._cmd("done", tracker.root) assert root.active_node is root.find( u"days > day > reference > task").one() setdt.increment(seconds=1) navigation._cmd("done", tracker.root) assert root.active_node is root.find( u"days > day > reference > task > task").one() setdt.increment(seconds=1) navigation._cmd("done", tracker.root) assert root.active_node is root.find( u"days > day > reference > task").one() setdt.increment(seconds=1) navigation._cmd("done", tracker.root) assert root.active_node is root.find( u"days > day > reference").one() setdt.increment(seconds=1) navigation._cmd("done", tracker.root) assert root.active_node is root.find( u"days > day").one() reference = tracker.root.find(u"days > day > reference").one() target_3 = tracker.root.find(u"** > \xfctarget 3").one() target_2 = tracker.root.find(u"** > \xfctarget 2").one() target_1 = tracker.root.find(u"\xfctarget 1").one() assert reference.started assert target_1.started assert target_2.started > target_1.started assert target_3.started > target_2.started assert target_3.finished > target_3.started assert target_2.finished > target_3.finished assert not target_1.finished assert reference.finished > target_2.finished
def test_start_stop(self): class SimpleActivateNode(Node): can_activate = True tracker = Tracker(skeleton=False, nodecreator=FakeNodeCreator(SimpleActivateNode)) tracker.root.activate(tracker.root.createchild("node1")) tracker.root.active_node.create("-> -node2: text") node3 = tracker.root.active_node.create("-> -node3: text") navigation._cmd("done", tracker.root) assert tracker.root.active_node is node3
def test_faroff_activate(setdt): setdt(2014, 3, 19, 20, 17) tracker = Tracker(skeleton=False) tracker.deserialize({"life": "days\n" " day: today\n" " @active\n" " day: March 25, 2014\n" }) navigation._cmd("create", tracker.root, "March 25, 2014 > task: something") navigation._cmd("activate", tracker.root, "March 25, 2014") with pytest.raises(searching.NoMatchesError): navigation._cmd("activate", tracker.root, "March 25, 2014 > task: something") assert tracker.root.active_node is tracker.root.find("today").one()
def test_unfinish(self, tracker, reftype): tracker.deserialize({"life": u"task#abcde: \xfctarget 1\n" u" task: \xfctarget 2\n" u"days\n" u" day: today\n" u" @active\n" u" {}: << >\n".format(reftype) }) navigation._cmd("done", tracker.root) refnode = tracker.root.find(u"** > " + reftype).one() assert tracker.root.active_node is refnode assert refnode.started assert not refnode.finished assert _dump([refnode]) == [ reftype + u": #abcde", u" proxy: task: \xfctarget 2" ] navigation._cmd("finish", tracker.root, u"<") target = tracker.root.find(u"task: \xfctarget 1").one() if reftype == u"depends": assert target.finished else: assert not target.finished assert refnode.finished assert _dump([refnode]) == [ reftype + u": #abcde" ] assert tracker.root.active_node.node_type == u"day" navigation._cmd("forceactivate", tracker.root, u">") assert tracker.root.active_node is refnode assert refnode.started assert not refnode.finished assert not target.finished assert _dump([refnode]) == [ reftype + u": #abcde", u" proxy: task: \xfctarget 2" ]