diff --git a/test/bug.425.t b/test/bug.425.t index 492d4d810..d91e4ce4b 100755 --- a/test/bug.425.t +++ b/test/bug.425.t @@ -1,62 +1,55 @@ -#! /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 => 1; +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", - "confirmation=off\n"; +class TestBug425(TestCase): + def setUp(self): + self.t = Task() - 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}; -qx{../src/task rc:$rc 1 modify Bar in Bar 2>&1}; +if __name__ == "__main__": + from simpletap import TAPTestRunner + unittest.main(testRunner=TAPTestRunner()) -my $output = qx{../src/task rc:$rc 1 ls 2>&1}; -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; +# vim: ai sts=4 et sw=4 diff --git a/test/bug.434.t b/test/bug.434.t deleted file mode 100755 index d99fadf75..000000000 --- a/test/bug.434.t +++ /dev/null @@ -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; - diff --git a/test/wait.t b/test/wait.t index db72c4bd4..88ee00338 100755 --- a/test/wait.t +++ b/test/wait.t @@ -1,86 +1,88 @@ -#! /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 => 7; +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", - "report.ls.columns=id,project,priority,description\n", - "report.ls.labels=ID,Proj,Pri,Description\n", - "report.ls.sort=priority-,project+\n", - "report.ls.filter=status:pending\n", - "confirmation=off\n"; - close $fh; -} +class TestWait(TestCase): + def setUp(self): + self.t = Task() + self.t.config("report.ls.columns", "id,project,priority,description") + self.t.config("report.ls.labels", "ID,Proj,Pri,Description") + self.t.config("report.ls.sort", "priority-,project+") + self.t.config("report.ls.filter", "status:pending") -# [1] add waited task that already expired -# [2] add waited task that is still waited -if (open my $fh, '>', 'pending.data') -{ - my $wait = time () - 3600; # Became visible an hour ago - my $entry = $wait - 86400; # Created a day ago - my $tomorrow = $wait + 86400; # Still waiting + def test_visibility_waiting(self): + """visibility of waiting tasks""" + # Create 2 tasks with waiting times: + # [1] an hour before current time (visible 'now') + # [2] 22 hours after current time (hidden 'now', visible 'tomorrow') + self.t.faketime("-2h") + self.t(("add", "wait:1h", "visible")) + self.t(("add", "wait:1d", "hidden")) - print $fh <&1}; -ok ($? == 0, "$ut: list tasks"); -like ($output, qr/visible/ms, "$ut: task 1 visible"); -unlike ($output, qr/invisible/ms, "$ut: task 2 invisible"); + self.t.faketime("+1d") + code, out, err = self.t(("ls",)) + self.assertIn("visible", out) + self.assertIn("hidden", out) -# 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 -$output = qx{../src/task rc:$rc 2 info 2>&1}; -ok ($? == 0, "$ut: 2 info"); -like ($output, qr/invisible/ms, "$ut: task 2 visible"); +class TestBug434(TestCase): + # Bug #434: Task shouldn't prevent users from marking as done tasks with + # status:waiting + def setUp(self): + self.t = Task() -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data), $rc; -exit 0; + def test_complete_waiting(self): + """completion of waiting tasks""" + 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