mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 14:36:44 +02:00
Test: Converted to Python
This commit is contained in:
parent
c230a4ad2c
commit
93f1bc531d
1 changed files with 117 additions and 153 deletions
|
@ -1,168 +1,132 @@
|
|||
#! /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 => 39;
|
||||
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";
|
||||
close $fh;
|
||||
}
|
||||
class TestPeriod(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Executed once before any test in the class"""
|
||||
|
||||
=pod
|
||||
http://github.com/pbeckingham/task/blob/857f813a24f7ce15fea9f2c28aadad84cb5c8847/src/task.cpp
|
||||
619 // If the period is an 'easy' one, add it to current, and we're done.
|
||||
620 int days = convertDuration (period);
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Task()
|
||||
|
||||
Date getNextRecurrence (Date& current, std::string& period)
|
||||
def test_recurrence_periods(self):
|
||||
"""Verify recurrence period special-case support
|
||||
|
||||
starting at line 509 special cases several possibilities for period, '\d\s?m'
|
||||
'monthly', 'quarterly', 'semiannual', 'bimonthly', 'biannual', 'biyearly'.
|
||||
Everything else falls through with period being passed to convertDuration.
|
||||
convertDuration doesn't know about 'daily' though so it seems to be returning 0.
|
||||
Date getNextRecurrence (Date& current, std::string& period)
|
||||
|
||||
Confirmed:
|
||||
getNextRecurrence convertDuration
|
||||
----------------- ---------------
|
||||
daily
|
||||
day
|
||||
weekly
|
||||
sennight
|
||||
biweekly
|
||||
fortnight
|
||||
monthly monthly
|
||||
quarterly quarterly
|
||||
semiannual semiannual
|
||||
bimonthly bimonthly
|
||||
biannual biannual
|
||||
biyearly biyearly
|
||||
annual
|
||||
yearly
|
||||
*m *m
|
||||
*q *q
|
||||
*d
|
||||
*w
|
||||
*y
|
||||
=cut
|
||||
starting at line 509 special cases several possibilities for period, '\d\s?m'
|
||||
'monthly', 'quarterly', 'semiannual', 'bimonthly', 'biannual', 'biyearly'.
|
||||
Everything else falls through with period being passed to convertDuration.
|
||||
convertDuration doesn't know about 'daily' though so it seems to be returning 0.
|
||||
|
||||
my $output = qx{../src/task rc:$rc add daily due:tomorrow recur:daily 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:daily");
|
||||
Confirmed:
|
||||
getNextRecurrence convertDuration
|
||||
----------------- ---------------
|
||||
daily
|
||||
day
|
||||
weekly
|
||||
sennight
|
||||
biweekly
|
||||
fortnight
|
||||
monthly monthly
|
||||
quarterly quarterly
|
||||
semiannual semiannual
|
||||
bimonthly bimonthly
|
||||
biannual biannual
|
||||
biyearly biyearly
|
||||
annual
|
||||
yearly
|
||||
*m *m
|
||||
*q *q
|
||||
*d
|
||||
*w
|
||||
*y
|
||||
"""
|
||||
|
||||
$output = qx{../src/task rc:$rc add 1day due:tomorrow recur:1day 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:1day");
|
||||
self.t("add daily due:tomorrow recur:daily")
|
||||
self.t("add 1day due:tomorrow recur:1day")
|
||||
self.t("add weekly due:tomorrow recur:weekly")
|
||||
self.t("add 1sennight due:tomorrow recur:1sennight")
|
||||
self.t("add biweekly due:tomorrow recur:biweekly")
|
||||
self.t("add fortnight due:tomorrow recur:fortnight")
|
||||
self.t("add monthly due:tomorrow recur:monthly")
|
||||
self.t("add quarterly due:tomorrow recur:quarterly")
|
||||
self.t("add semiannual due:tomorrow recur:semiannual")
|
||||
self.t("add bimonthly due:tomorrow recur:bimonthly")
|
||||
self.t("add biannual due:tomorrow recur:biannual")
|
||||
self.t("add biyearly due:tomorrow recur:biyearly")
|
||||
self.t("add annual due:tomorrow recur:annual")
|
||||
self.t("add yearly due:tomorrow recur:yearly")
|
||||
self.t("add 2d due:tomorrow recur:2d")
|
||||
self.t("add 2w due:tomorrow recur:2w")
|
||||
self.t("add 2mo due:tomorrow recur:2mo")
|
||||
self.t("add 2q due:tomorrow recur:2q")
|
||||
self.t("add 2y due:tomorrow recur:2y")
|
||||
|
||||
$output = qx{../src/task rc:$rc add weekly due:tomorrow recur:weekly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:weekly");
|
||||
# Verify that the recurring task instances were created. One of each.
|
||||
code, out, err = self.t("list")
|
||||
self.assertIn(" daily ", out);
|
||||
self.assertIn(" 1day ", out);
|
||||
self.assertIn(" weekly ", out);
|
||||
self.assertIn(" 1sennight ", out);
|
||||
self.assertIn(" biweekly ", out);
|
||||
self.assertIn(" fortnight ", out);
|
||||
self.assertIn(" monthly ", out);
|
||||
self.assertIn(" quarterly ", out);
|
||||
self.assertIn(" semiannual ", out);
|
||||
self.assertIn(" bimonthly ", out);
|
||||
self.assertIn(" biannual ", out);
|
||||
self.assertIn(" biyearly ", out);
|
||||
self.assertIn(" annual ", out);
|
||||
self.assertIn(" yearly ", out);
|
||||
self.assertIn(" 2d ", out);
|
||||
self.assertIn(" 2w ", out);
|
||||
self.assertIn(" 2mo ", out);
|
||||
self.assertIn(" 2q ", out);
|
||||
self.assertIn(" 2y ", out);
|
||||
|
||||
$output = qx{../src/task rc:$rc add 1sennight due:tomorrow recur:1sennight 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:1sennight");
|
||||
# Duplicate check
|
||||
code, out, err = self.t("diag")
|
||||
self.assertIn("No duplicates found", out)
|
||||
|
||||
$output = qx{../src/task rc:$rc add biweekly due:tomorrow recur:biweekly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:biweekly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add fortnight due:tomorrow recur:fortnight 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:fortnight");
|
||||
|
||||
$output = qx{../src/task rc:$rc add monthly due:tomorrow recur:monthly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:monthly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add quarterly due:tomorrow recur:quarterly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:quarterly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add semiannual due:tomorrow recur:semiannual 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:semiannual");
|
||||
|
||||
$output = qx{../src/task rc:$rc add bimonthly due:tomorrow recur:bimonthly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:bimonthly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add biannual due:tomorrow recur:biannual 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:biannual");
|
||||
|
||||
$output = qx{../src/task rc:$rc add biyearly due:tomorrow recur:biyearly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:biyearly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add annual due:tomorrow recur:annual 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:annual");
|
||||
|
||||
$output = qx{../src/task rc:$rc add yearly due:tomorrow recur:yearly 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:yearly");
|
||||
|
||||
$output = qx{../src/task rc:$rc add 2d due:tomorrow recur:2d 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:2d");
|
||||
|
||||
$output = qx{../src/task rc:$rc add 2w due:tomorrow recur:2w 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:2w");
|
||||
|
||||
$output = qx{../src/task rc:$rc add 2m due:tomorrow recur:2mo 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:2m");
|
||||
|
||||
$output = qx{../src/task rc:$rc add 2q due:tomorrow recur:2q 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:2q");
|
||||
|
||||
$output = qx{../src/task rc:$rc add 2y due:tomorrow recur:2y 2>&1};
|
||||
unlike ($output, qr/was not recognized/, "$ut: recur:2y");
|
||||
|
||||
# Verify that the recurring task instances get created. One of each.
|
||||
$output = qx{../src/task rc:$rc list 2>&1};
|
||||
like ($output, qr/\bdaily\b/, "$ut: verify daily");
|
||||
like ($output, qr/\b1day\b/, "$ut: verify 1day");
|
||||
like ($output, qr/\bweekly\b/, "$ut: verify weekly");
|
||||
like ($output, qr/\b1sennight\b/, "$ut: verify 1sennight");
|
||||
like ($output, qr/\bbiweekly\b/, "$ut: verify biweekly");
|
||||
like ($output, qr/\bfortnight\b/, "$ut: verify fortnight");
|
||||
like ($output, qr/\bmonthly\b/, "$ut: verify monthly");
|
||||
like ($output, qr/\bquarterly\b/, "$ut: verify quarterly");
|
||||
like ($output, qr/\bsemiannual\b/, "$ut: verify semiannual");
|
||||
like ($output, qr/\bbimonthly\b/, "$ut: verify bimonthly");
|
||||
like ($output, qr/\bbiannual\b/, "$ut: verify biannual");
|
||||
like ($output, qr/\bbiyearly\b/, "$ut: verify biyearly");
|
||||
like ($output, qr/\bannual\b/, "$ut: verify annual");
|
||||
like ($output, qr/\byearly\b/, "$ut: verify yearly");
|
||||
like ($output, qr/\b2d\b/, "$ut: verify 2d");
|
||||
like ($output, qr/\b2w\b/, "$ut: verify 2w");
|
||||
like ($output, qr/\b2m\b/, "$ut: verify 2m");
|
||||
like ($output, qr/\b2q\b/, "$ut: verify 2q");
|
||||
like ($output, qr/\b2y\b/, "$ut: verify 2y");
|
||||
|
||||
$output = qx{../src/task rc:$rc diag 2>&1};
|
||||
like ($output, qr/No duplicates found/, "$ut: No duplicate UUIDs detected");
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue