mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tests: Merge uda_<type>.t to uda.t and convert to Python
This commit is contained in:
parent
5c788bf198
commit
c0286c58de
7 changed files with 234 additions and 411 deletions
234
test/uda.t
Executable file
234
test/uda.t
Executable file
|
@ -0,0 +1,234 @@
|
|||
#!/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
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
# NOTE Test classes are ordered alphabetically
|
||||
|
||||
|
||||
class TestBaseUda(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
self.t.config("uda.extra.label", "Extra")
|
||||
self.t.config("report.uda.description", "UDA Test")
|
||||
self.t.config("report.uda.columns", "id,extra,description")
|
||||
self.t.config("report.uda.sort", "extra,description")
|
||||
self.t.config("report.uda.labels", "ID,Extra,Description")
|
||||
|
||||
|
||||
class TestUdaDate(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaDate, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "date")
|
||||
self.t.config("dateformat", "m/d/Y")
|
||||
|
||||
def test_uda_date_task(self):
|
||||
"""Add tasks with and without an UDA date"""
|
||||
|
||||
code, out, err = self.t(("add", "with", "extra:tomorrow"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("add", "without"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+[\d\/]+\s+with")
|
||||
self.assertRegexpMatches(out, "2\s+without")
|
||||
|
||||
def test_uda_bad_date_task(self):
|
||||
"""Add tasks with an invalid UDA date"""
|
||||
code, out, err = self.t.runError(("add", "bad", "extra:bad_date"))
|
||||
self.assertNotIn("Created task", out)
|
||||
self.assertIn("not a valid date", err)
|
||||
|
||||
|
||||
class TestUdaDefault(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaDefault, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "numeric")
|
||||
self.t.config("uda.smell.type", "string")
|
||||
self.t.config("uda.smell.label", "Smell")
|
||||
self.t.config("uda.smell.values", "weak,strong")
|
||||
self.t.config("uda.smell.default", "weak")
|
||||
|
||||
self.t.config("report.uda.columns", "id,smell,extra,description")
|
||||
self.t.config("report.uda.sort", "id")
|
||||
self.t.config("report.uda.labels", "ID,Smell,Size,Description")
|
||||
|
||||
def test_uda_nondefault_task(self):
|
||||
"""Add tasks with non default UDA"""
|
||||
|
||||
code, out, err = self.t(("add", "one", "smell:strong"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+strong\s+one")
|
||||
|
||||
def test_uda_default_task(self):
|
||||
"""Add tasks with default UDA"""
|
||||
|
||||
code, out, err = self.t(("add", "two"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+weak\s+two")
|
||||
|
||||
def test_uda_without_default_task(self):
|
||||
"""Add tasks without default UDA"""
|
||||
|
||||
code, out, err = self.t(("add", "three", "extra:10"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+weak\s+10\s+three")
|
||||
|
||||
|
||||
class TestUdaDuration(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaDuration, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "duration")
|
||||
|
||||
def test_uda_duration_task(self):
|
||||
"""Add tasks with and without an UDA duration"""
|
||||
|
||||
code, out, err = self.t(("add", "with", "extra:1day"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("add", "without"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+P1D\s+with")
|
||||
self.assertRegexpMatches(out, "2\s+without")
|
||||
|
||||
# Ensure 'extra' is stored in original form.
|
||||
code, out, err = self.t(("1", "export"))
|
||||
self.assertRaisesRegexp(out, '"extra":"1day"')
|
||||
|
||||
def test_uda_bad_duration_task(self):
|
||||
"""Add tasks with an invalid UDA duration"""
|
||||
code, out, err = self.t.runError(("add", "bad", "extra:bad_duration"))
|
||||
self.assertNotIn("Created task", out)
|
||||
self.assertIn("The duration value 'bad_duration' is not supported",
|
||||
err)
|
||||
|
||||
|
||||
class TestUdaNumeric(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaNumeric, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "numeric")
|
||||
|
||||
def test_uda_numeric_task(self):
|
||||
"""Add tasks with and without an UDA numeric"""
|
||||
|
||||
code, out, err = self.t(("add", "with", "extra:123"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("add", "without"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+\d+\s+with")
|
||||
self.assertRegexpMatches(out, "2\s+without")
|
||||
|
||||
def test_uda_bad_numeric_task(self):
|
||||
"""Add tasks with an invalid UDA numeric"""
|
||||
code, out, err = self.t.runError(("add", "bad", "extra:bad_numeric"))
|
||||
self.assertNotIn("Created task", out)
|
||||
self.assertIn("The value 'bad_numeric' is not a valid numeric value",
|
||||
err)
|
||||
|
||||
|
||||
class TestUdaString(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaString, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "string")
|
||||
|
||||
def test_uda_string_task(self):
|
||||
"""Add tasks with and without an UDA string"""
|
||||
|
||||
code, out, err = self.t(("add", "with", "extra:'one two'"))
|
||||
self.assertIn("Created task", out)
|
||||
code, out, err = self.t(("add", "without"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+one two\s+with")
|
||||
self.assertRegexpMatches(out, "2\s+without")
|
||||
|
||||
|
||||
class TestUdaValue(TestBaseUda):
|
||||
def setUp(self):
|
||||
super(TestUdaValue, self).setUp()
|
||||
|
||||
self.t.config("uda.extra.type", "string")
|
||||
self.t.config("uda.extra.values", "weak,strong")
|
||||
|
||||
def test_uda_value_task(self):
|
||||
"""Add tasks with valid UDA values"""
|
||||
|
||||
code, out, err = self.t(("add", "one", "extra:weak"))
|
||||
self.assertIn("Created task", out)
|
||||
code, out, err = self.t(("add", "two", "extra:strong"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+weak\s+one")
|
||||
self.assertRegexpMatches(out, "2\s+strong\s+two")
|
||||
|
||||
def test_uda_invalid_value_task(self):
|
||||
"""Add tasks with invalid UDA value"""
|
||||
|
||||
code, out, err = self.t(("add", "one", "extra:strong"))
|
||||
self.assertIn("Created task", out)
|
||||
|
||||
code, out, err = self.t.runError(("add", "two", "extra:toxic"))
|
||||
self.assertIn("The 'extra' attribute does not allow a value of "
|
||||
"'toxic'", err)
|
||||
|
||||
code, out, err = self.t(("uda",))
|
||||
self.assertRegexpMatches(out, "1\s+strong\s+one")
|
||||
self.assertNotRegexpMatches(out, "1\s+toxic\s+two")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
|
@ -1,65 +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 => 3;
|
||||
|
||||
# Ensure environment has no influence.
|
||||
delete $ENV{'TASKDATA'};
|
||||
delete $ENV{'TASKRC'};
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'uda.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"confirmation=off\n",
|
||||
"uda.extra.type=date\n",
|
||||
"uda.extra.label=Extra\n",
|
||||
"report.uda.description=UDA Test\n",
|
||||
"report.uda.columns=id,extra,description\n",
|
||||
"report.uda.sort=extra,description\n",
|
||||
"report.uda.labels=ID,Extra,Description\n",
|
||||
"dateformat=m/d/Y\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add tasks with and without the UDA.
|
||||
qx{../src/task rc:uda.rc add with extra:tomorrow 2>&1};
|
||||
qx{../src/task rc:uda.rc add without 2>&1};
|
||||
my $output = qx{../src/task rc:uda.rc uda 2>&1};
|
||||
like ($output, qr/1\s+[\d\/]+\s+with/, 'UDA date stored');
|
||||
like ($output, qr/2\s+without/, 'UDA date blank');
|
||||
|
||||
# Add bad data.
|
||||
$output = qx{../src/task rc:uda.rc add bad extra:unrecognized_date 2>&1};
|
||||
unlike ($output, qr/Created task \d+/, 'UDA date bad data not accepted');
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data uda.rc);
|
||||
exit 0;
|
||||
|
|
@ -1,78 +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 => 6;
|
||||
|
||||
# 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",
|
||||
"uda.smell.type=string\n",
|
||||
"uda.smell.label=Smell\n",
|
||||
"uda.smell.values=weak,strong\n",
|
||||
"uda.smell.default=weak\n",
|
||||
"uda.size.type=numeric\n",
|
||||
"uda.size.label=Size\n",
|
||||
"report.uda.description=UDA Test\n",
|
||||
"report.uda.columns=id,smell,size,description\n",
|
||||
"report.uda.sort=id\n",
|
||||
"report.uda.labels=ID,Smell,Size,Description\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add task with nondefault UDA
|
||||
my $output = qx{../src/task rc:$rc add one smell:strong 2>&1};
|
||||
like ($output, qr/Created task 1/, "$ut: Add 1 - no errors");
|
||||
|
||||
# Add task without a UDA value, checking for usage of the default
|
||||
$output = qx{../src/task rc:$rc add two 2>&1};
|
||||
like ($output, qr/Created task 2/, "$ut: Add 2 - no errors");
|
||||
|
||||
# Add a task with a UDA that has no default, ensure it is entered fine
|
||||
$output = qx{../src/task rc:$rc add three size:10 2>&1};
|
||||
like ($output, qr/Created task 3/, "$ut: Add 3 - no errors");
|
||||
|
||||
$output = qx{../src/task rc:$rc uda 2>&1};
|
||||
like ($output, qr/1\s+strong\s+one/, "$ut: UDA nondefault stored");
|
||||
like ($output, qr/2\s+weak\s+two/, "$ut: UDA default stored");
|
||||
like ($output, qr/3\s+weak\s+10\s+three/, "$ut: UDA without default stored");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
|
@ -1,72 +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 => 4;
|
||||
|
||||
# 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",
|
||||
"uda.extra.type=duration\n",
|
||||
"uda.extra.label=Extra\n",
|
||||
"report.uda.description=UDA Test\n",
|
||||
"report.uda.columns=id,extra,description\n",
|
||||
"report.uda.sort=extra,description\n",
|
||||
"report.uda.labels=ID,Extra,Description\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add tasks with and without the UDA.
|
||||
qx{../src/task rc:$rc add with extra:1day 2>&1};
|
||||
qx{../src/task rc:$rc add without 2>&1};
|
||||
my $output = qx{../src/task rc:$rc uda 2>&1};
|
||||
like ($output, qr/1\s+P1D\s+with/, "$ut: UDA duration stored");
|
||||
like ($output, qr/2\s+without/, "$ut: UDA duration blank");
|
||||
|
||||
# Ensure 'extra' is stored in original form.
|
||||
$output = qx{../src/task rc:$rc 1 export 2>&1};
|
||||
like ($output, qr/"extra":"1day"/, "$ut: UDA duration stored as is");
|
||||
|
||||
# Add bad data.
|
||||
$output = qx{../src/task rc:$rc add bad extra:unrecognized_duration 2>&1};
|
||||
unlike ($output, qr/Created task \d+/, "$ut: UDA duration bad data not accepted");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
|
@ -1,68 +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 => 3;
|
||||
|
||||
# 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",
|
||||
"uda.extra.type=numeric\n",
|
||||
"uda.extra.label=Extra\n",
|
||||
"report.uuu.description=UDA Test\n",
|
||||
"report.uuu.columns=id,extra,description\n",
|
||||
"report.uuu.sort=extra,description\n",
|
||||
"report.uuu.labels=ID,Extra,Description\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add tasks with and without the UDA.
|
||||
qx{../src/task rc:$rc add with extra:123 2>&1};
|
||||
qx{../src/task rc:$rc add without 2>&1};
|
||||
my $output = qx{../src/task rc:$rc uuu 2>&1};
|
||||
like ($output, qr/1\s+\d+\s+with/, "$ut: UDA numeric stored");
|
||||
like ($output, qr/2\s+without/, "$ut: UDA numeric blank");
|
||||
|
||||
# Add bad data.
|
||||
$output = qx{../src/task rc:$rc add bad extra:unrecognized_numeric 2>&1};
|
||||
unlike ($output, qr/Created task \d+/, "$ut: UDA numeric bad data not accepted");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
|
@ -1,64 +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 => 2;
|
||||
|
||||
# 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",
|
||||
"uda.extra.type=string\n",
|
||||
"uda.extra.label=Extra\n",
|
||||
"report.uuu.description=UDA Test\n",
|
||||
"report.uuu.columns=id,extra,description\n",
|
||||
"report.uuu.sort=extra,description\n",
|
||||
"report.uuu.labels=ID,Extra,Description\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add tasks with and without the UDA.
|
||||
qx{../src/task rc:$rc add with extra:"one two" 2>&1};
|
||||
qx{../src/task rc:$rc add without 2>&1};
|
||||
my $output = qx{../src/task rc:$rc uuu 2>&1};
|
||||
like ($output, qr/1\s+one two\s+with/, "$ut: UDA string stored");
|
||||
like ($output, qr/2\s+without/, "$ut: UDA string blank");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
|
@ -1,64 +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 => 3;
|
||||
|
||||
# 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",
|
||||
"uda.smell.type=string\n",
|
||||
"uda.smell.label=Smell\n",
|
||||
"uda.smell.values=weak,strong\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Add tasks with valid and invalid UDA values.
|
||||
my $output = qx{../src/task rc:$rc add one smell:weak 2>&1};
|
||||
like ($output, qr/Created task 1/, "$ut: UDA smell:weak allowed");
|
||||
|
||||
$output = qx{../src/task rc:$rc add two smell:strong 2>&1};
|
||||
like ($output, qr/Created task 2/, "$ut: UDA smell:strong allowed");
|
||||
|
||||
$output = qx{../src/task rc:$rc add three smell:toxic 2>&1};
|
||||
unlike ($output, qr/Created task 3/, "$ut: UDA smell:toxic disallowed");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue