mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Tests: bug.425, bug_434 and wait now in python
This commit is contained in:
parent
4dd09ca13f
commit
cd3a848bad
3 changed files with 124 additions and 187 deletions
|
@ -1,62 +1,55 @@
|
||||||
#! /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 => 1;
|
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'};
|
|
||||||
|
|
||||||
use File::Basename;
|
|
||||||
my $ut = basename ($0);
|
|
||||||
my $rc = $ut . '.rc';
|
|
||||||
|
|
||||||
# Create the rc file.
|
class TestBug425(TestCase):
|
||||||
if (open my $fh, '>', $rc)
|
def setUp(self):
|
||||||
{
|
self.t = Task()
|
||||||
print $fh "data.location=.\n",
|
|
||||||
"confirmation=off\n";
|
|
||||||
|
|
||||||
close $fh;
|
def test_bug425(self):
|
||||||
}
|
"""parser interpret 'in' in description"""
|
||||||
|
self.t(("add", "Foo"))
|
||||||
|
self.t(("1", "modify", "Bar in Bar"))
|
||||||
|
|
||||||
# Bug #425: Parser preventing editing of an existing task depending on description
|
code, out, err = self.t(("1", "ls"))
|
||||||
|
self.assertRegexpMatches(out, "1\s+Bar in Bar")
|
||||||
|
|
||||||
# Create a task and attempt to revise the description to include the word 'in'
|
|
||||||
# (this breaks in 1.9.3 and earlier)
|
|
||||||
|
|
||||||
qx{../src/task rc:$rc add Foo 2>&1};
|
if __name__ == "__main__":
|
||||||
qx{../src/task rc:$rc 1 modify Bar in Bar 2>&1};
|
from simpletap import TAPTestRunner
|
||||||
|
unittest.main(testRunner=TAPTestRunner())
|
||||||
|
|
||||||
my $output = qx{../src/task rc:$rc 1 ls 2>&1};
|
# vim: ai sts=4 et sw=4
|
||||||
like ($output, qr/1\s+Bar in Bar/m, "$ut: parser - interpret \'in\' in description");
|
|
||||||
|
|
||||||
# Cleanup.
|
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
|
||||||
exit 0;
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
#! /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
|
|
||||||
##
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Test::More tests => 1;
|
|
||||||
|
|
||||||
# Ensure environment has no influence.
|
|
||||||
delete $ENV{'TASKDATA'};
|
|
||||||
delete $ENV{'TASKRC'};
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bug #434: Task shouldn't prevent users from marking as done tasks with status:waiting
|
|
||||||
|
|
||||||
# Add a task that is waiting
|
|
||||||
qx{../src/task rc:$rc add One wait:tomorrow 2>&1};
|
|
||||||
my $output = qx{../src/task rc:$rc 1 done 2>&1};
|
|
||||||
like ($output, qr/Completed 1 task\./, "$ut: Waiting task marked completed");
|
|
||||||
|
|
||||||
# Cleanup.
|
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
|
||||||
exit 0;
|
|
||||||
|
|
154
test/wait.t
154
test/wait.t
|
@ -1,86 +1,88 @@
|
||||||
#! /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 => 7;
|
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'};
|
|
||||||
|
|
||||||
use File::Basename;
|
|
||||||
my $ut = basename ($0);
|
|
||||||
my $rc = $ut . '.rc';
|
|
||||||
|
|
||||||
# Create the rc file.
|
class TestWait(TestCase):
|
||||||
if (open my $fh, '>', $rc)
|
def setUp(self):
|
||||||
{
|
self.t = Task()
|
||||||
print $fh "data.location=.\n",
|
self.t.config("report.ls.columns", "id,project,priority,description")
|
||||||
"report.ls.columns=id,project,priority,description\n",
|
self.t.config("report.ls.labels", "ID,Proj,Pri,Description")
|
||||||
"report.ls.labels=ID,Proj,Pri,Description\n",
|
self.t.config("report.ls.sort", "priority-,project+")
|
||||||
"report.ls.sort=priority-,project+\n",
|
self.t.config("report.ls.filter", "status:pending")
|
||||||
"report.ls.filter=status:pending\n",
|
|
||||||
"confirmation=off\n";
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# [1] add waited task that already expired
|
def test_visibility_waiting(self):
|
||||||
# [2] add waited task that is still waited
|
"""visibility of waiting tasks"""
|
||||||
if (open my $fh, '>', 'pending.data')
|
# Create 2 tasks with waiting times:
|
||||||
{
|
# [1] an hour before current time (visible 'now')
|
||||||
my $wait = time () - 3600; # Became visible an hour ago
|
# [2] 22 hours after current time (hidden 'now', visible 'tomorrow')
|
||||||
my $entry = $wait - 86400; # Created a day ago
|
self.t.faketime("-2h")
|
||||||
my $tomorrow = $wait + 86400; # Still waiting
|
self.t(("add", "wait:1h", "visible"))
|
||||||
|
self.t(("add", "wait:1d", "hidden"))
|
||||||
|
|
||||||
print $fh <<eof;
|
self.t.faketime()
|
||||||
[uuid:"00000000-0000-0000-0000-000000000000" status:"waiting" description:"visible" entry:"$entry" wait:"$wait"]
|
code, out, err = self.t(("ls",))
|
||||||
[uuid:"00000000-0000-0000-0000-000000000001" status:"waiting" description:"invisible" entry:"$entry" wait:"$tomorrow"]
|
self.assertIn("visible", out)
|
||||||
eof
|
self.assertNotIn("hidden", out)
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# verify [1] visible already
|
self.t.faketime("+1d")
|
||||||
# verify [2] inviѕible
|
code, out, err = self.t(("ls",))
|
||||||
my $output = qx{../src/task rc:$rc ls 2>&1};
|
self.assertIn("visible", out)
|
||||||
ok ($? == 0, "$ut: list tasks");
|
self.assertIn("hidden", out)
|
||||||
like ($output, qr/visible/ms, "$ut: task 1 visible");
|
|
||||||
unlike ($output, qr/invisible/ms, "$ut: task 2 invisible");
|
|
||||||
|
|
||||||
# verify [1] has status:pending
|
|
||||||
$output = qx{../src/task rc:$rc 1 info 2>&1};
|
|
||||||
ok ($? == 0, "$ut: 1 info");
|
|
||||||
like ($output, qr/Status\s+Pending/ms, "$ut: task 1 pending");
|
|
||||||
|
|
||||||
# verify [2] visible via info
|
class TestBug434(TestCase):
|
||||||
$output = qx{../src/task rc:$rc 2 info 2>&1};
|
# Bug #434: Task shouldn't prevent users from marking as done tasks with
|
||||||
ok ($? == 0, "$ut: 2 info");
|
# status:waiting
|
||||||
like ($output, qr/invisible/ms, "$ut: task 2 visible");
|
def setUp(self):
|
||||||
|
self.t = Task()
|
||||||
|
|
||||||
# Cleanup.
|
def test_complete_waiting(self):
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
"""completion of waiting tasks"""
|
||||||
exit 0;
|
self.t(("add", "One", "wait:tomorrow"))
|
||||||
|
|
||||||
|
code, out, err = self.t(("1", "done"))
|
||||||
|
self.assertIn("Completed 1 task", out)
|
||||||
|
|
||||||
|
code, out, err = self.t.runError(("ls",))
|
||||||
|
self.assertNotIn("One", out)
|
||||||
|
self.assertIn("No matches", err)
|
||||||
|
|
||||||
|
|
||||||
|
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