mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Test: Converted to Python
This commit is contained in:
parent
19baeba5da
commit
fc97513aa4
2 changed files with 54 additions and 83 deletions
|
@ -36,10 +36,6 @@ from basetest import Task, TestCase
|
||||||
|
|
||||||
|
|
||||||
class TestCalendarCommandLine(TestCase):
|
class TestCalendarCommandLine(TestCase):
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
"""Executed once before any test in the class"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
self.t = Task()
|
self.t = Task()
|
||||||
|
|
|
@ -1,89 +1,64 @@
|
||||||
#! /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 Test::More tests => 6;
|
import unittest
|
||||||
|
# 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'};
|
|
||||||
|
|
||||||
# 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')
|
class TestDateformat(TestCase):
|
||||||
{
|
@classmethod
|
||||||
print $fh "data.location=.\n",
|
def setUpClass(cls):
|
||||||
"dateformat=m/d/y\n",
|
"""Executed once before any test in the class"""
|
||||||
"dateformat.info=m/d/y\n",
|
cls.t = Task()
|
||||||
"dateformat.report=m/d/y\n";
|
cls.t.config("report.xxx.columns", "id,due")
|
||||||
close $fh;
|
cls.t.config("report.xxx.labels", "ID,DUE")
|
||||||
}
|
cls.t.config("report.xxx.sort", "id")
|
||||||
|
|
||||||
if (open my $fh, '>', 'date3.rc')
|
def setUp(self):
|
||||||
{
|
"""Executed before each test in the class"""
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
qx{../src/task rc:date1.rc add foo due:20091231 2>&1};
|
def test_alternate_dateformats(self):
|
||||||
my $output = qx{../src/task rc:date1.rc info 1 2>&1};
|
"""Verify a variety of dateformats elements succeed"""
|
||||||
like ($output, qr/\b20091231\b/, 'date format YMD parsed');
|
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';
|
code, out, err = self.t("xxx rc.dateformat:YMDTHNS")
|
||||||
ok (!-r 'pending.data', 'Removed pending.data');
|
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';
|
if __name__ == "__main__":
|
||||||
ok (!-r 'pending.data', 'Removed pending.data');
|
from simpletap import TAPTestRunner
|
||||||
|
unittest.main(testRunner=TAPTestRunner())
|
||||||
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;
|
|
||||||
|
|
||||||
|
# vim: ai sts=4 et sw=4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue