From c0df2b9f70783d97c54b49fdd70da602f9eacc79 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 24 Jun 2015 22:08:58 -0400 Subject: [PATCH] Test; Converted to Python, removed unnecessary tests --- test/count.t | 117 +++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 65 deletions(-) diff --git a/test/count.t b/test/count.t index c01adc053..00d56a4e5 100755 --- a/test/count.t +++ b/test/count.t @@ -1,75 +1,62 @@ -#! /usr/bin/env perl -################################################################################ -## -## Copyright 2006 - 2015, 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 -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ +#!/usr/bin/env python2.7 +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright 2006 - 2015, 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# http://www.opensource.org/licenses/mit-license.php +# +############################################################################### -use strict; -use warnings; -use POSIX qw(mktime); -use Test::More tests => 5; +import sys +import os +import unittest +# Ensure python finds the local simpletap module +sys.path.append(os.path.dirname(os.path.abspath(__file__))) -# Ensure environment has no influence. -delete $ENV{'TASKDATA'}; -delete $ENV{'TASKRC'}; +from basetest import Task, TestCase -use File::Basename; -my $ut = basename ($0); -my $rc = $ut . '.rc'; -# Create the rc file. -if (open my $fh, '>', $rc) -{ - print $fh "data.location=.\n", - "confirmation=off\n"; - close $fh; -} +class TestCount(TestCase): -# Test the count command. -qx{../src/task rc:$rc add one 2>&1}; -qx{../src/task rc:$rc log two 2>&1}; -qx{../src/task rc:$rc add three 2>&1}; -qx{../src/task rc:$rc 2 delete 2>&1}; -qx{../src/task rc:$rc add four wait:eom 2>&1}; -qx{../src/task rc:$rc add five due:eom recur:monthly 2>&1}; + @classmethod + def setUpClass(cls): + """Executed once before any test in the class""" + cls.t = Task() + cls.t(("add", "one")) + cls.t(("log", "two")) + cls.t(("add", "three")) + cls.t(("1", "delete")) -my $output = qx{../src/task rc:$rc count 2>&1}; -like ($output, qr/^5\n/ms, "$ut: count"); + def test_count_unfiltered(self): + code, out, err = self.t(("count",)) + self.assertEqual(out.strip(), "3") -$output = qx{../src/task rc:$rc count status:deleted rc.debug:1 2>&1}; -like ($output, qr/^1\n/ms, "$ut: count status:deleted"); + def test_count_filtered(self): + code, out, err = self.t(("status:deleted", "count")) + self.assertEqual(out.strip(), "1") -$output = qx{../src/task rc:$rc count e 2>&1}; -like ($output, qr/^3\n/ms, "$ut: count e"); -$output = qx{../src/task rc:$rc count description.startswith:f 2>&1}; -like ($output, qr/^2\n/ms, "$ut: count description.startswith:f"); - -$output = qx{../src/task rc:$rc count due.any: 2>&1}; -like ($output, qr/^1\n/ms, "$ut: count due.any:"); - -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data), $rc; -exit 0; +if __name__ == "__main__": + from simpletap import TAPTestRunner + unittest.main(testRunner=TAPTestRunner()) +# vim: ai sts=4 et sw=4