From de2c08ab827444886409122c65776f96c9aa753d Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Sun, 20 Jan 2019 23:16:12 +0100 Subject: [PATCH] Add test for joining closed and open interval --- test/join.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/join.t b/test/join.t index dbe7c06d..d234f1db 100755 --- a/test/join.t +++ b/test/join.t @@ -68,7 +68,29 @@ class TestJoin(TestCase): expectedEnd="{:%Y%m%dT%H%M%S}Z".format(one_hour_before_utc), expectedTags=["foo"]) - # TODO Add :adjust tests. + def test_join_closed_and_open_interval(self): + """Join closed and open interval""" + now = datetime.now() + now_utc = now.utcnow() + + one_hour_before_utc = now_utc - timedelta(hours=1) + two_hours_before_utc = now_utc - timedelta(hours=2) + 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("start {:%Y-%m-%dT%H:%M:%S}Z bar".format(two_hours_before_utc, one_hour_before_utc)) + + code, out, err = self.t("join @1 @2") + + self.assertIn('Joined @1 and @2', out) + + j = self.t.export() + + self.assertEqual(len(j), 1) + self.assertOpenInterval(j[0], + expectedStart="{:%Y%m%dT%H%M%S}Z".format(five_hours_before_utc), + expectedTags=["foo"]) if __name__ == "__main__":