Get and use filter from CLI when processing DOM references

- Closes #188

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2020-05-08 17:08:49 +02:00
parent 13f1de2c49
commit a508dd21ea
2 changed files with 33 additions and 1 deletions

View file

@ -197,6 +197,38 @@ class TestDOMTracked(TestCase):
code, out, err = self.t("get dom.tracked.tags")
self.assertEqual("bar foo \n", out)
def test_dom_tracked_tags_filtered_by_time(self):
"""Test dom.tracked.tags with tags filtered by time"""
now_utc = datetime.now().utcnow()
one_hour_before_utc = now_utc - timedelta(hours=1)
two_hours_before_utc = now_utc - timedelta(hours=2)
three_hours_before_utc = now_utc - timedelta(hours=3)
four_hours_before_utc = now_utc - timedelta(hours=4)
five_hours_before_utc = now_utc - timedelta(hours=5)
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z foo".format(five_hours_before_utc, four_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z bar".format(three_hours_before_utc, two_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z baz".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("get dom.tracked.tags {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z".format(five_hours_before_utc, two_hours_before_utc))
self.assertEqual("bar foo \n", out)
def test_dom_tracked_tags_filtered_by_tag(self):
"""Test dom.tracked.tags with tags filtered by tag"""
now_utc = datetime.now().utcnow()
one_hour_before_utc = now_utc - timedelta(hours=1)
two_hours_before_utc = now_utc - timedelta(hours=2)
three_hours_before_utc = now_utc - timedelta(hours=3)
four_hours_before_utc = now_utc - timedelta(hours=4)
five_hours_before_utc = now_utc - timedelta(hours=5)
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z foo".format(five_hours_before_utc, four_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z bar".format(three_hours_before_utc, two_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z foo baz".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("get dom.tracked.tags foo")
self.assertEqual("baz foo \n", out)
def test_dom_tracked_N_tag_count_zero(self):
"""Test dom.tracked.N.tag.count with zero tags"""
self.t("track :yesterday one two")