mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Test: Converted to Python
This commit is contained in:
parent
94048fae0f
commit
dd10f6da6b
1 changed files with 84 additions and 75 deletions
159
test/delete.t
159
test/delete.t
|
@ -1,89 +1,98 @@
|
|||
#! /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 => 12;
|
||||
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=no\n";
|
||||
close $fh;
|
||||
}
|
||||
class TestDelete(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Executed once before any test in the class"""
|
||||
|
||||
# Add a task, delete it, undelete it.
|
||||
my $output = qx{../src/task rc:$rc add one 2>&1; ../src/task rc:$rc info 1 2>&1};
|
||||
ok (-r 'pending.data', "$ut: pending.data created");
|
||||
like ($output, qr/Status\s+Pending\n/, "$ut: Pending");
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Task()
|
||||
|
||||
$output = qx{../src/task rc:$rc 1 delete 2>&1; ../src/task rc:$rc info 1 2>&1};
|
||||
like ($output, qr/Status\s+Deleted\n/, "$ut: Deleted");
|
||||
def test_add_delete_undo(self):
|
||||
"""Verify that add/delete/undo yields a Pending task"""
|
||||
self.t("add one")
|
||||
code, out, err = self.t("_get 1.uuid")
|
||||
uuid = out.strip()
|
||||
|
||||
$output = qx{../src/task rc:$rc undo 2>&1; ../src/task rc:$rc info 1 2>&1};
|
||||
like ($output, qr/Status\s+Pending\n/, "$ut: Pending");
|
||||
self.t("1 delete")
|
||||
self.t.runError("list") # GC/handleRecurrence
|
||||
code, out, err = self.t("_get 1.status")
|
||||
self.assertEqual("\n", out)
|
||||
|
||||
$output = qx{../src/task rc:$rc 1 delete 2>&1; ../src/task rc:$rc list 2>&1 >/dev/null};
|
||||
like ($output, qr/No matches./, "$ut: No matches");
|
||||
ok (-r 'completed.data', "$ut: completed.data created");
|
||||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
self.assertIn("deleted\n", out)
|
||||
|
||||
$output = qx{../src/task rc:$rc info 1 2>&1 >/dev/null};
|
||||
like ($output, qr/No matches\./, "$ut: No matches");
|
||||
self.t("undo")
|
||||
code, out, err = self.t("_get 1.status")
|
||||
self.assertIn("pending\n", out)
|
||||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
self.assertIn("pending\n", out)
|
||||
|
||||
# Add a task, delete it, and modify on the fly.
|
||||
qx{../src/task rc:$rc add one two 2>&1};
|
||||
$output = qx{../src/task rc:$rc list 2>&1};
|
||||
like ($output, qr/one two/, "$ut: Second task added");
|
||||
def test_delete_en_passant(self):
|
||||
"""Verify that en-passant works with delete"""
|
||||
self.t("add foo")
|
||||
code, out, err = self.t("1 delete project:work")
|
||||
self.assertIn("Deleted 1 task.", out)
|
||||
|
||||
qx{../src/task rc:$rc 1 delete foo pri:H 2>&1};
|
||||
$output = qx{../src/task rc:$rc 1 info 2>&1};
|
||||
like ($output, qr/foo/, "$ut: Deletion annotation successful");
|
||||
like ($output, qr/H/, "$ut: Deletion modification successful");
|
||||
code, out, err = self.t("all rc.verbose:nothing")
|
||||
self.assertIn("work", out)
|
||||
|
||||
# Add a task, complete it, then delete it.
|
||||
qx{../src/task rc:$rc add three 2>&1};
|
||||
$output = qx{../src/task rc:$rc 2 info 2>&1};
|
||||
like ($output, qr/three/, "$ut: added and verified new task");
|
||||
my ($uuid) = $output =~ /UUID\s+(\S+)/;
|
||||
qx{../src/task rc:$rc 2 done 2>&1};
|
||||
qx{../src/task rc:$rc $uuid delete 2>&1};
|
||||
$output = qx{../src/task rc:$rc $uuid info 2>&1};
|
||||
like ($output, qr/Deleted/, "$ut: task added, completed, then deleted");
|
||||
def test_add_done_delete(self):
|
||||
"""Verify that a completed task can be deleted"""
|
||||
self.t("add foo")
|
||||
code, out, err = self.t("_get 1.uuid")
|
||||
uuid = out.strip()
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
code, out, err = self.t("1 done")
|
||||
self.assertIn("Completed 1 task.", out)
|
||||
|
||||
self.t("all") # GC/handleRecurrence
|
||||
|
||||
code, out, err = self.t("%s delete" % uuid)
|
||||
self.assertIn("Deleted 1 task.", out)
|
||||
|
||||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
self.assertIn("deleted\n", out)
|
||||
|
||||
|
||||
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