Test: Converted to Python

This commit is contained in:
Paul Beckingham 2015-07-22 21:10:48 -04:00
parent 8b278adea6
commit e1f01c46ae

View file

@ -1,71 +1,69 @@
#! /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 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'};
# Create the rc file.
if (open my $fh, '>', 'feature.rc')
{
print $fh "data.location=.\n",
"confirmation=off\n";
close $fh;
}
# Feature 725: Feedback when tasks become unblocked. class TestFeature725(TestCase):
qx{../src/task rc:feature.rc add one 2>&1}; def setUp(self):
qx{../src/task rc:feature.rc add two 2>&1}; """Executed before each test in the class"""
qx{../src/task rc:feature.rc add three 2>&1}; self.t = Task()
qx{../src/task rc:feature.rc add four 2>&1};
qx{../src/task rc:feature.rc 1 modify depends:2,3 2>&1};
qx{../src/task rc:feature.rc 4 modify depends:1 2>&1};
my $output = qx{../src/task rc:feature.rc long 2>&1};
like ($output, qr/1.+2\s3/, 'Dependencies in place [1]');
like ($output, qr/4.+1/, 'Dependencies in place [4]');
# Trigger the feedback based on completion. def test_unbocked_feedback(self):
$output = qx{../src/task rc:feature.rc 2 done 2>&1}; """Verify that when a task becomes unblocked, feedback is generated"""
unlike ($output, qr/Unblocked/, 'Completing first dependency does not trigger message'); self.t("add one")
self.t("add two")
self.t("add three")
self.t("add four")
self.t("1 modify depends:2,3")
self.t("4 modify depends:1")
$output = qx{../src/task rc:feature.rc 3 done 2>&1}; # 2 does not unblock 1.
like ($output, qr/Unblocked/, 'Completing second dependency triggers message'); code, out, err = self.t("2 done")
self.assertNotIn("Unblocked", out)
# Now trigger the feedback based on deletion. # 2 and 3 do unblock 1.
$output = qx{../src/task rc:feature.rc long 2>&1}; code, out, err = self.t("3 done")
like ($output, qr/2.+1/, 'Dependencies in place [2]'); self.assertIn("Unblocked", out)
$output = qx{../src/task rc:feature.rc 1 delete 2>&1};
like ($output, qr/Unblocked/, 'Deleting dependency triggers message');
# Cleanup. # 1 does unblock 4.
unlink qw(pending.data completed.data undo.data backlog.data feature.rc); code, out, er = self.t("1 delete")
exit 0; self.assertIn("Unblocked", out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4