Permalink
Browse files

Update tests

  • Loading branch information...
lauft committed Jul 31, 2018
1 parent cdc2e7f commit ebe7de59976465216fb8a05500d9c20c454c17a1
Showing with 89 additions and 4 deletions.
  1. +31 −1 test/start.t
  2. +31 −2 test/tag.t
  3. +27 −1 test/track.t
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2018, Paul Beckingham, Federico Hernandez.
# Copyright 2006 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -30,6 +30,8 @@ import os
import sys
import unittest

from datetime import datetime, timedelta

# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

@@ -222,6 +224,34 @@ class TestStart(TestCase):
self.assertTrue('tags' in j[1])
self.assertEqual(j[1]['tags'][0], 'foo')

def test_start_with_new_tag(self):
"""Call 'start' with new tag"""
now_utc = datetime.now().utcnow()

two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("start {:%Y-%m-%dT%H:%M:%S} bar".format(now_utc))

self.assertIn("Note: 'bar' is a new tag", out)
self.assertIn("Tracking bar", out)

def test_start_with_previous_tag(self):
"""Call 'start' with previous tag"""
now_utc = datetime.now().utcnow()

three_hours_before_utc = now_utc - timedelta(hours=3)
two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(three_hours_before_utc, two_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("start {:%Y-%m-%dT%H:%M:%S} bar".format(now_utc))

self.assertNotIn("Note: 'bar' is a new tag", out)
self.assertIn("Tracking bar", out)


if __name__ == "__main__":
from simpletap import TAPTestRunner
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2018, Paul Beckingham, Federico Hernandez.
# Copyright 2006 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -123,7 +123,7 @@ class TestTag(TestCase):
self.t("track 2016-01-01T00:00:00 - 2016-01-01T01:00:00 one")
self.t("track 2016-01-01T01:00:00 - 2016-01-01T02:00:00 two")
code, out, err = self.t("tag @1 @2 foo bar")
self.assertIn('Added foo bar to @1\nAdded foo bar to @2', out)
self.assertIn("Added foo bar to @1\nAdded foo bar to @2", out)

j = self.t.export()
self.assertClosedInterval(j[0], expectedTags=["bar", "foo", "one"])
@@ -169,6 +169,7 @@ class TestTag(TestCase):
description="unmodified interval")

def test_tag_with_identical_ids(self):
"""Call 'tag' with identical ids"""
self.t("track 2016-01-01T00:00:00 - 2016-01-01T01:00:00")
self.t("tag @1 @1 foo")

@@ -177,6 +178,34 @@ class TestTag(TestCase):
self.assertEquals(len(j), 1)
self.assertClosedInterval(j[0], expectedTags=["foo"])

def test_tag_with_new_tag(self):
"""Call 'tag' with new tag"""
now_utc = datetime.now().utcnow()

two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("tag @1 bar")

self.assertIn("Note: 'bar' is a new tag", out)
self.assertIn("Added bar to @1", out)

def test_tag_with_previous_tag(self):
"""Call 'tag' with previous tag"""
now_utc = datetime.now().utcnow()

three_hours_before_utc = now_utc - timedelta(hours=3)
two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(three_hours_before_utc, two_hours_before_utc))
self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("tag @1 bar")

self.assertNotIn("Note: 'bar' is a new tag", out)
self.assertIn("Added bar to @1", out)


if __name__ == "__main__":
from simpletap import TAPTestRunner
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2018, Paul Beckingham, Federico Hernandez.
# Copyright 2006 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -113,6 +113,32 @@ class TestTrack(TestCase):
j = self.t.export()
self.assertTrue(len(j) > 0)

def test_track_with_new_tag(self):
"""Call 'track' with new tag"""
now_utc = datetime.now().utcnow()

two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(one_hour_before_utc, now_utc))

self.assertIn("Note: 'bar' is a new tag", out)
self.assertIn("Recorded bar", out)

def test_track_with_previous_tag(self):
"""Call 'track' with previous tag"""
now_utc = datetime.now().utcnow()

two_hours_before_utc = now_utc - timedelta(hours=2)
one_hour_before_utc = now_utc - timedelta(hours=1)

self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(two_hours_before_utc, one_hour_before_utc))
code, out, err = self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(one_hour_before_utc, now_utc))

self.assertNotIn("Note: 'bar' is a new tag", out)
self.assertIn("Recorded bar", out)


if __name__ == "__main__":
from simpletap import TAPTestRunner

0 comments on commit ebe7de5

Please sign in to comment.