mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Test: Convert uuid.t and add test for TW-1636
This commit is contained in:
parent
6100933a28
commit
ceee9caee8
1 changed files with 145 additions and 106 deletions
251
test/uuid.t
251
test/uuid.t
|
@ -1,120 +1,159 @@
|
||||||
#! /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 => 22;
|
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 TestUUID(TestCase):
|
||||||
if (open my $fh, '>', $rc)
|
def setUp(self):
|
||||||
{
|
self.t = Task()
|
||||||
print $fh "data.location=.\n",
|
|
||||||
"dateformat=m/d/Y\n",
|
|
||||||
"report.unittest.columns=id,entry,start,description\n",
|
|
||||||
"report.unittest.filter=status:pending\n",
|
|
||||||
"report.unittest.sort=id\n",
|
|
||||||
"confirmation=off\n";
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (open my $fh, '>', 'pending.data')
|
self.t.config("dateformat", "m/d/Y")
|
||||||
{
|
|
||||||
print $fh <<EOF;
|
|
||||||
[description:"one" entry:"1315260230" status:"pending" uuid:"9deed7ca-843d-4259-b2c4-40ce73e8e4f3"]
|
|
||||||
[description:"two" entry:"1315260230" status:"pending" uuid:"0f4c83d2-552f-4108-ae3f-ccc7959f84a3"]
|
|
||||||
[description:"three" entry:"1315260230" status:"pending" uuid:"aa4abef1-1dc5-4a43-b6a0-7872df3094bb"]
|
|
||||||
[description:"ssttaarrtt" entry:"1315335826" start:"1315338535" status:"pending" uuid:"d71d3566-7a6b-4c32-8f0b-6de75bb9397b"]
|
|
||||||
EOF
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (open my $fh, '>', 'completed.data')
|
self.t("import -", input="""[
|
||||||
{
|
{"description":"one", "entry":"1315260230", "status":"pending", "uuid":"9deed7ca-843d-4259-b2c4-40ce73e8e4f3"},
|
||||||
print $fh <<EOF;
|
{"description":"two", "entry":"1315260230", "status":"pending", "uuid":"0f4c83d2-552f-4108-ae3f-ccc7959f84a3"},
|
||||||
[description:"four" end:"1315260230" entry:"1315260230" status:"completed" uuid:"ea3b4822-574c-464b-8025-7f7be9f3cc57"]
|
{"description":"three", "entry":"1315260230", "status":"pending", "uuid":"aa4abef1-1dc5-4a43-b6a0-7872df3094bb"},
|
||||||
[description:"five" end:"1315260230" entry:"1315260230" status:"completed" uuid:"0f38b97e-3081-4e75-a1be-65ed3712ea4d"]
|
{"description":"four", "end":"1315260230", "entry":"1315260230", "status":"completed", "uuid":"ea3b4822-574c-464b-8025-7f7be9f3cc57"},
|
||||||
[description:"eenndd" end:"1315335841" entry:"1315335841" start:"1315338516" status:"completed" uuid:"727baa6c-65b8-485e-a810-e133e3cd83dc"]
|
{"description":"ssttaarrtt", "entry":"1315335826", "start":"1315338535", "status":"pending", "uuid":"d71d3566-7a6b-4c32-8f0b-6de75bb9397b"},
|
||||||
[description:"UUNNDDOO" end:"1315338626" entry:"1315338626" status:"completed" uuid:"c1361003-948e-43e8-85c8-15d28dc3c71c"]
|
{"description":"five", "end":"1315260230", "entry":"1315260230", "status":"completed", "uuid":"0f38b97e-3081-4e75-a1be-65ed3712ea4d"},
|
||||||
EOF
|
{"description":"six", "end":"1315338826", "entry":"1315338726", "status":"completed", "uuid":"12345678-1234-1234-1234-123456789012"},
|
||||||
close $fh;
|
{"description":"seven", "end":"1315338826", "entry":"1315338726", "status":"completed", "uuid":"abcdefab-abcd-abcd-abcd-abcdefabcdef"},
|
||||||
}
|
{"description":"eenndd", "end":"1315335841", "entry":"1315335841", "start":"1315338516", "status":"completed", "uuid":"727baa6c-65b8-485e-a810-e133e3cd83dc"},
|
||||||
|
{"description":"UUNNDDOO", "end":"1315338626", "entry":"1315338626", "status":"completed", "uuid":"c1361003-948e-43e8-85c8-15d28dc3c71c"}
|
||||||
|
]""")
|
||||||
|
|
||||||
qx{../src/task rc:$rc 9deed7ca-843d-4259-b2c4-40ce73e8e4f3 modify ONE 2>&1};
|
def _config_unittest_report(self):
|
||||||
qx{../src/task rc:$rc 2 modify TWO 2>&1};
|
self.t.config("report.unittest.columns", "id,entry,start,description")
|
||||||
my $output = qx{../src/task rc:$rc list 2>&1};
|
self.t.config("report.unittest.filter", "status:pending")
|
||||||
like ($output, qr/ONE/, 'task list ONE');
|
self.t.config("report.unittest.sort", "id")
|
||||||
like ($output, qr/TWO/, 'task list TWO');
|
|
||||||
like ($output, qr/three/, 'task list three');
|
|
||||||
like ($output, qr/ssttaarrtt/, 'task list ssttaarrtt');
|
|
||||||
unlike ($output, qr/four/, 'task does not list four');
|
|
||||||
unlike ($output, qr/five/, 'task does not list five');
|
|
||||||
unlike ($output, qr/eenndd/, 'task does not list eenndd');
|
|
||||||
unlike ($output, qr/UUNNDDOO/, 'task does not list UUNNDDOO');
|
|
||||||
|
|
||||||
qx{../src/task rc:$rc ea3b4822-574c-464b-8025-7f7be9f3cc57 modify FOUR 2>&1};
|
def test_uuid_modify_pending(self):
|
||||||
$output = qx{../src/task rc:$rc completed 2>&1};
|
"""Modify with UUID + report pending"""
|
||||||
unlike ($output, qr/ONE/, 'task does not list ONE');
|
self.t("9deed7ca-843d-4259-b2c4-40ce73e8e4f3 modify ONE")
|
||||||
unlike ($output, qr/TWO/, 'task does not list TWO');
|
self.t("2 modify TWO")
|
||||||
unlike ($output, qr/three/, 'task does not list three');
|
code, out, err = self.t("list")
|
||||||
unlike ($output, qr/ssttaarrtt/, 'task does not list ssttaarrtt');
|
|
||||||
like ($output, qr/FOUR/, 'modified completed task FOUR');
|
|
||||||
like ($output, qr/five/, 'did not modify task five');
|
|
||||||
like ($output, qr/eenndd/, 'did not modify task eenndd');
|
|
||||||
like ($output, qr/UUNNDDOO/, 'did not modify task UUNNDDOO');
|
|
||||||
|
|
||||||
qx{../src/task rc:$rc c1361003-948e-43e8-85c8-15d28dc3c71c modify status:pending 2>&1};
|
self.assertIn("ONE", out)
|
||||||
$output = qx{../src/task rc:$rc list 2>&1};
|
self.assertIn("TWO", out)
|
||||||
like ($output, qr/UUNNDDOO/, 'task UUNNDDOO modified status to pending');
|
self.assertIn("three", out)
|
||||||
$output = qx{../src/task rc:$rc completed 2>&1};
|
self.assertIn("ssttaarrtt", out)
|
||||||
unlike ($output, qr/UUNNDDOO/, 'task does not list UUNNDDOO after modification');
|
self.assertNotIn("four", out)
|
||||||
|
self.assertNotIn("five", out)
|
||||||
|
self.assertNotIn("six", out)
|
||||||
|
self.assertNotIn("seven", out)
|
||||||
|
self.assertNotIn("eenndd", out)
|
||||||
|
self.assertNotIn("UUNNDDOO", out)
|
||||||
|
|
||||||
qx{../src/task rc:$rc d71d3566-7a6b-4c32-8f0b-6de75bb9397b modify start:12/31/2010 2>&1};
|
def test_uuid_modify_completed(self):
|
||||||
$output = qx{../src/task rc:$rc unittest 2>&1};
|
"""Modify with UUID + report completed"""
|
||||||
like ($output, qr/12\/31\/2010/, 'modified start date of task ssttaarrtt');
|
self.t("ea3b4822-574c-464b-8025-7f7be9f3cc57 modify FOUR")
|
||||||
|
code, out, err = self.t("completed")
|
||||||
|
|
||||||
qx{../src/task rc:$rc 727baa6c-65b8-485e-a810-e133e3cd83dc modify end:12/31/2010 2>&1};
|
self.assertNotIn("ONE", out)
|
||||||
$output = qx{../src/task rc:$rc completed 2>&1};
|
self.assertNotIn("TWO", out)
|
||||||
like ($output, qr/12\/31\/2010/, 'modified end date of task eenndd');
|
self.assertNotIn("three", out)
|
||||||
|
self.assertNotIn("ssttaarrtt", out)
|
||||||
|
self.assertIn("FOUR", out)
|
||||||
|
self.assertIn("five", out)
|
||||||
|
self.assertIn("six", out)
|
||||||
|
self.assertIn("seven", out)
|
||||||
|
self.assertIn("eenndd", out)
|
||||||
|
self.assertIn("UUNNDDOO", out)
|
||||||
|
|
||||||
qx{../src/task rc:$rc aa4abef1-1dc5-4a43-b6a0-7872df3094bb modify entry:12/30/2010 2>&1};
|
def test_uuid_modify_status(self):
|
||||||
qx{../src/task rc:$rc aa4abef1-1dc5-4a43-b6a0-7872df3094bb modify start:1/1/2011 2>&1};
|
"""Modify status: with UUID"""
|
||||||
$output = qx{../src/task rc:$rc unittest 2>&1};
|
self.t("c1361003-948e-43e8-85c8-15d28dc3c71c modify status:pending")
|
||||||
like ($output, qr/12\/30\/2010/, 'modified entry date of task three');
|
|
||||||
like ($output, qr/1\/1\/2011/, 'added start date of task three with modify');
|
|
||||||
|
|
||||||
# Cleanup.
|
code, out, err = self.t("list")
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
self.assertIn("UUNNDDOO", out)
|
||||||
exit 0;
|
|
||||||
|
|
||||||
|
code, out, err = self.t("completed")
|
||||||
|
self.assertNotIn("UUNNDDOO", out)
|
||||||
|
|
||||||
|
def test_uuid_modify_start(self):
|
||||||
|
"""Modify start: with UUID"""
|
||||||
|
self._config_unittest_report()
|
||||||
|
|
||||||
|
self.t("d71d3566-7a6b-4c32-8f0b-6de75bb9397b modify start:12/31/2010")
|
||||||
|
|
||||||
|
code, out, err = self.t("unittest")
|
||||||
|
self.assertIn("12/31/2010", out)
|
||||||
|
|
||||||
|
def test_uuid_modify_end(self):
|
||||||
|
"""Modify end: with UUID"""
|
||||||
|
self.t("727baa6c-65b8-485e-a810-e133e3cd83dc modify end:12/31/2010")
|
||||||
|
|
||||||
|
code, out, err = self.t("completed")
|
||||||
|
self.assertIn("12/31/2010", out)
|
||||||
|
|
||||||
|
def test_uuid_modify_start_end(self):
|
||||||
|
"""Modify start: and end: with UUID"""
|
||||||
|
self._config_unittest_report()
|
||||||
|
|
||||||
|
self.t("aa4abef1-1dc5-4a43-b6a0-7872df3094bb modify entry:12/30/2010")
|
||||||
|
self.t("aa4abef1-1dc5-4a43-b6a0-7872df3094bb modify start:1/1/2011")
|
||||||
|
|
||||||
|
code, out, err = self.t("unittest")
|
||||||
|
self.assertIn("12/30/2010", out)
|
||||||
|
self.assertIn("1/1/2011", out)
|
||||||
|
|
||||||
|
def test_numerical_uuid(self):
|
||||||
|
"""Using numerical UUID"""
|
||||||
|
# NOTE: Reported on TW-1636
|
||||||
|
self.t("12345678-1234-1234-1234-123456789012 modify status:completed")
|
||||||
|
|
||||||
|
code, out, err = self.t("_get 12345678-1234-1234-1234-123456789012.status")
|
||||||
|
self.assertIn("completed\n", out)
|
||||||
|
|
||||||
|
code, out, err = self.t("12345678-1234-1234-1234-123456789012 export")
|
||||||
|
self.assertIn("'description':'six'", out)
|
||||||
|
|
||||||
|
def test_alpha_uuid(self):
|
||||||
|
"""Using alphabetic UUID"""
|
||||||
|
# NOTE: complement numerical only reported on TW-1636
|
||||||
|
self.t("abcdefab-abcd-abcd-abcd-abcdefabcdef modify status:completed")
|
||||||
|
|
||||||
|
code, out, err = self.t("_get abcdefab-abcd-abcd-abcd-abcdefabcdef.status")
|
||||||
|
self.assertIn("completed\n", out)
|
||||||
|
|
||||||
|
code, out, err = self.t("abcdefab-abcd-abcd-abcd-abcdefabcdef export")
|
||||||
|
self.assertIn('"description":"seven"', 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