From 197815a3a788787882c9fb25bd73dedb2603caa6 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Fri, 6 Mar 2015 15:10:07 +0000 Subject: [PATCH] Tests - convert bug.1036.t to python --- test/bug.1036.t | 112 +++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/test/bug.1036.t b/test/bug.1036.t index 2da7d19d0..579d91516 100755 --- a/test/bug.1036.t +++ b/test/bug.1036.t @@ -1,63 +1,67 @@ -#! /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 => 2; +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", - "dateformat=m/d/Y\n"; - close $fh; -} +class TestBug1036(TestCase): + "'until' attribute should be modifiable in non-recurring tasks" -# Bug #1036: prevents 'until' attributes to be modified for non-recurring -# tasks. + def setUp(self): + self.t = Task() -# Check that until attribute may be modified -qx{../src/task rc:$rc add test 2>&1}; -my $output = qx{../src/task rc:$rc 1 mod until:1/1/2020 2>&1}; -like ($output, qr/^Modifying task 1 'test'.$/ms, "$ut: 'until' attribute added"); + self.t.config("dateformat", "m/d/Y") -qx{../src/task rc:$rc add test until:1/1/2020 2>&1}; -$output = qx{../src/task rc:$rc 1 mod /test/Test/ 2>&1}; -like ($output, qr/^Modifying task 1 'Test'.$/ms, "$ut: Task with 'until' attribute modified"); + def test_until_may_modify(self): + """check that until attribute may be modified""" + self.t(("add", "test")) + code, out, err = self.t(("1", "mod", "until:1/1/2020")) -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data), $rc; -exit 0; + expected = "Modifying task 1 'test'." + self.assertIn(expected, out) + def test_may_modify_on_until(self): + """check that task with until attribute set may be modified""" + self.t(("add", "test", "until:1/1/2020")) + code, out, err = self.t(("1", "mod", "/test/Hello/")) + + expected = "Modifying task 1 'Hello'." + self.assertIn(expected, out) + + +if __name__ == "__main__": + from simpletap import TAPTestRunner + unittest.main(testRunner=TAPTestRunner()) + +# vim: ai sts=4 et sw=4