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
e0275d404f
commit
937820a883
1 changed files with 64 additions and 57 deletions
121
test/bug.837.t
121
test/bug.837.t
|
@ -1,68 +1,75 @@
|
||||||
#! /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 => 3;
|
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 TestBug837(TestCase):
|
||||||
if (open my $fh, '>', $rc)
|
@classmethod
|
||||||
{
|
def setUpClass(cls):
|
||||||
print $fh "data.location=.\n";
|
"""Executed once before any test in the class"""
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bug 837: When a task is completed, tasks that depended upon it don't have
|
def setUp(self):
|
||||||
# correct urgency and depend on 0 when edited
|
"""Executed before each test in the class"""
|
||||||
qx{../src/task rc:$rc add one 2>&1};
|
self.t = Task()
|
||||||
qx{../src/task rc:$rc add two dep:1 2>&1};
|
|
||||||
qx{../src/task rc:$rc long 2>&1};
|
|
||||||
|
|
||||||
my $output = qx{../src/task rc:$rc 1 _urgency 2>&1};
|
def test_unblocked_urgency(self):
|
||||||
like ($output, qr/ 8\n/, "$ut: blocking urgency == 8");
|
"""Verify urgency goes to zero after unblocking
|
||||||
|
|
||||||
$output = qx{../src/task rc:$rc 2 _urgency 2>&1};
|
Bug 837: When a task is completed, tasks that depended upon it do not
|
||||||
like ($output, qr/ -5\n/, "$ut: blocked urgency == -5");
|
have the correct urgency and depend on 0 when edited
|
||||||
|
"""
|
||||||
|
|
||||||
qx{../src/task rc:$rc 1 done 2>&1};
|
self.t("add one")
|
||||||
qx{../src/task rc:$rc list 2>&1};
|
self.t("add two dep:1")
|
||||||
|
self.t("list") # GC/handleRecurrence
|
||||||
|
|
||||||
$output = qx{../src/task rc:$rc 1 _urgency 2>&1};
|
code, out, err = self.t("_get 1.urgency")
|
||||||
like ($output, qr/ 0\n/, "$ut: unblocked urgency == 0");
|
self.assertEqual("8\n", out)
|
||||||
|
|
||||||
# Cleanup.
|
code, out, err = self.t("_get 2.urgency")
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
self.assertEqual("-5\n", out)
|
||||||
exit 0;
|
|
||||||
|
|
||||||
|
self.t("1 done")
|
||||||
|
self.t("list") # GC/handleRecurrence
|
||||||
|
|
||||||
|
code, out, err = self.t("_get 1.urgency")
|
||||||
|
self.assertEqual("0\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