Test: Converted to Python

This commit is contained in:
Paul Beckingham 2015-07-23 19:09:45 -04:00
parent 19baeba5da
commit fc97513aa4
2 changed files with 54 additions and 83 deletions

View file

@ -36,10 +36,6 @@ from basetest import Task, TestCase
class TestCalendarCommandLine(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
def setUp(self):
"""Executed before each test in the class"""
self.t = Task()

View file

@ -1,89 +1,64 @@
#! /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 Test::More tests => 6;
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
# Create the rc file.
if (open my $fh, '>', 'date1.rc')
{
print $fh "data.location=.\n",
"dateformat=YMD\n",
"dateformat.info=YMD\n",
"dateformat.report=YMD\n";
close $fh;
}
if (open my $fh, '>', 'date2.rc')
{
print $fh "data.location=.\n",
"dateformat=m/d/y\n",
"dateformat.info=m/d/y\n",
"dateformat.report=m/d/y\n";
close $fh;
}
class TestDateformat(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,due")
cls.t.config("report.xxx.labels", "ID,DUE")
cls.t.config("report.xxx.sort", "id")
if (open my $fh, '>', 'date3.rc')
{
print $fh "data.location=.\n",
"dateformat=m/d/y\n",
"dateformat=m/d/y\n",
"weekstart=Monday\n",
"dateformat.info=A D B Y (wV)\n",
"dateformat.report=A D B Y (wV)\n";
close $fh;
}
def setUp(self):
"""Executed before each test in the class"""
qx{../src/task rc:date1.rc add foo due:20091231 2>&1};
my $output = qx{../src/task rc:date1.rc info 1 2>&1};
like ($output, qr/\b20091231\b/, 'date format YMD parsed');
def test_alternate_dateformats(self):
"""Verify a variety of dateformats elements succeed"""
self.t("add foo rc.dateformat:'y/M/D' due:15/07/04")
self.t("add foo rc.dateformat:'m/d/y_h:n:s' due:7/4/15_0:0:0")
self.t("add foo rc.dateformat:'YMDHNS' due:20150704000000")
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
code, out, err = self.t("xxx rc.dateformat:YMDTHNS")
self.assertEqual(out.count("20150704T000000"), 3)
qx{../src/task rc:date2.rc add foo due:12/1/09 2>&1};
$output = qx{../src/task rc:date2.rc info 1 2>&1};
like ($output, qr/\b12\/1\/09\b/, 'date format m/d/y parsed');
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
qx{../src/task rc:date3.rc add foo due:4/8/10 2>&1};
$output = qx{../src/task rc:date3.rc list 2>&1};
like ($output, qr/Thursday 08 April 2010 \(w14\)/, 'date format A D B Y (wV) parsed');
$output = qx{../src/task rc:date3.rc rc.dateformat.report:"D b Y - a" list 2>&1};
like ($output, qr/08 Apr 2010 - Thu/, 'date format D b Y - a parsed');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data date1.rc date2.rc date3.rc);
exit 0;
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4