mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +02:00
Tests - convert bug.1063.t to python
This commit is contained in:
parent
7cc410f58e
commit
920cdcca10
1 changed files with 66 additions and 64 deletions
130
test/bug.1063.t
130
test/bug.1063.t
|
@ -1,72 +1,74 @@
|
||||||
#! /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 => 6;
|
import re
|
||||||
|
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 TestBug1063(TestCase):
|
||||||
if (open my $fh, '>', $rc)
|
def setUp(self):
|
||||||
{
|
self.t = Task()
|
||||||
print $fh "data.location=.\n",
|
|
||||||
"confirmation=off\n",
|
|
||||||
"uda.foo.type=numeric\n",
|
|
||||||
"uda.foo.label=Foo\n",
|
|
||||||
"report.bar.columns=foo,description\n",
|
|
||||||
"report.bar.description=Bar\n",
|
|
||||||
"report.bar.labels=Foo,Desc\n",
|
|
||||||
"report.bar.sort=foo-\n";
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bug 1063 - Numeric UDA fields are not sortable.
|
self.t.config("uda.foo.type", "numeric")
|
||||||
qx{../src/task rc:$rc add four foo:4 2>&1};
|
self.t.config("uda.foo.label", "Foo")
|
||||||
ok ($? == 0, "$ut: add four");
|
self.t.config("report.bar.columns", "foo,description")
|
||||||
qx{../src/task rc:$rc add one foo:1 2>&1};
|
self.t.config("report.bar.description", "Bar")
|
||||||
ok ($? == 0, "$ut: add one");
|
self.t.config("report.bar.labels", "Foo,Desc")
|
||||||
qx{../src/task rc:$rc add three foo:3 2>&1};
|
self.t.config("report.bar.sort", "foo-")
|
||||||
ok ($? == 0, "$ut: add three");
|
|
||||||
qx{../src/task rc:$rc add two foo:2 2>&1};
|
|
||||||
ok ($? == 0, "$ut: add two");
|
|
||||||
|
|
||||||
my $output = qx{../src/task rc:$rc bar 2>&1};
|
def test_sortable_uda(self):
|
||||||
like ($output, qr/4.+3.+2.+1/ms, "$ut: Default descending sort correct");
|
"""numeric UDA fields are sortable
|
||||||
|
|
||||||
$output = qx{../src/task rc:$rc bar rc.report.bar.sort=foo+ 2>&1};
|
Reported as bug 1063
|
||||||
like ($output, qr/1.+2.+3.+4/ms, "$ut: Default ascending sort correct");
|
"""
|
||||||
|
|
||||||
## Cleanup.
|
self.t(("add", "four", "foo:4"))
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
self.t(("add", "one", "foo:1"))
|
||||||
exit 0;
|
self.t(("add", "three", "foo:3"))
|
||||||
|
self.t(("add", "two", "foo:2"))
|
||||||
|
|
||||||
|
code, out, err = self.t(("bar",))
|
||||||
|
expected = re.compile("4.+3.+2.+1", re.DOTALL) # dot matches \n too
|
||||||
|
self.assertRegexpMatches(out, expected)
|
||||||
|
|
||||||
|
code, out, err = self.t(("bar", "rc.report.bar.sort=foo+"))
|
||||||
|
expected = re.compile("1.+2.+3.+4", re.DOTALL) # dot matches \n too
|
||||||
|
self.assertRegexpMatches(out, expected)
|
||||||
|
|
||||||
|
|
||||||
|
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