Test; Converted to Python, removed unnecessary tests

This commit is contained in:
Paul Beckingham
2015-06-24 22:08:58 -04:00
parent 7e8f6eb41e
commit c0df2b9f70

View File

@@ -1,75 +1,62 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
################################################################################ # -*- coding: utf-8 -*-
## ###############################################################################
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. #
## # 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 # Permission is hereby granted, free of charge, to any person obtaining a copy
## in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights
## copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## furnished to do so, subject to the following conditions: # 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 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, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## SOFTWARE. # 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 #
## # http://www.opensource.org/licenses/mit-license.php
################################################################################ #
###############################################################################
use strict; import sys
use warnings; import os
use POSIX qw(mktime); import unittest
use Test::More tests => 5; # Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestCount(TestCase):
if (open my $fh, '>', $rc)
{
print $fh "data.location=.\n",
"confirmation=off\n";
close $fh;
}
# Test the count command. @classmethod
qx{../src/task rc:$rc add one 2>&1}; def setUpClass(cls):
qx{../src/task rc:$rc log two 2>&1}; """Executed once before any test in the class"""
qx{../src/task rc:$rc add three 2>&1}; cls.t = Task()
qx{../src/task rc:$rc 2 delete 2>&1}; cls.t(("add", "one"))
qx{../src/task rc:$rc add four wait:eom 2>&1}; cls.t(("log", "two"))
qx{../src/task rc:$rc add five due:eom recur:monthly 2>&1}; cls.t(("add", "three"))
cls.t(("1", "delete"))
my $output = qx{../src/task rc:$rc count 2>&1}; def test_count_unfiltered(self):
like ($output, qr/^5\n/ms, "$ut: count"); 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}; def test_count_filtered(self):
like ($output, qr/^1\n/ms, "$ut: count status:deleted"); 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}; if __name__ == "__main__":
like ($output, qr/^2\n/ms, "$ut: count description.startswith:f"); from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
$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;
# vim: ai sts=4 et sw=4