From 84b621301bbbb6d72502a8b8acf6f9d0d9604825 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 13 Mar 2014 00:50:45 -0400 Subject: [PATCH 1/4] Add test to check for the proper tags on the branch --- tests/utils/test_bzr_tags.py | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tests/utils/test_bzr_tags.py diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py new file mode 100644 index 000000000..e463aa08b --- /dev/null +++ b/tests/utils/test_bzr_tags.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test for proper bzr tags. +""" + +from unittest import TestCase + +import subprocess + +from subprocess import Popen, PIPE + +TAGS = [ + ['1.9.0', '1'], + ['1.9.1', '775'], + ['1.9.2', '890'], + ['1.9.3', '1063'], + ['1.9.4', '1196'], + ['1.9.5', '1421'], + ['1.9.6', '1657'], + ['1.9.7', '1761'], + ['1.9.8', '1856'], + ['1.9.9', '1917'], + ['1.9.10', '2003'], + ['1.9.11', '2039'], + ['1.9.12', '2063'], + ['2.0', '2118'], + ['2.0.1', '?'], + ['2.0.2', '?'], + ['2.0.3', '?'], + ['2.1.0', '2119'] +] + + +class TestBzrTags(TestCase): + + def bzr_tags_test(self): + """ + Test for proper bzr tags + """ + # GIVEN: A bzr branch + + # WHEN getting the branches tags + tags = [] + bzr = Popen(('bzr', 'tags'), stdout=PIPE) + stdout = bzr.communicate()[0] + lines = (line.decode('utf-8') for line in stdout.splitlines()) + for line in lines: + tags.append(line.split()) + + # THEN the tags should match the accepted tags + self.assertEqual(TAGS, tags, 'List of tags should match') From 2b55c1ceb5c1d473244d52533c515ce9ff471671 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 13 Mar 2014 17:36:01 -0400 Subject: [PATCH 2/4] Change test to use a black list instead of a white list. --- tests/utils/test_bzr_tags.py | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index e463aa08b..e9b6b35bc 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -32,30 +32,9 @@ Package to test for proper bzr tags. from unittest import TestCase -import subprocess - from subprocess import Popen, PIPE -TAGS = [ - ['1.9.0', '1'], - ['1.9.1', '775'], - ['1.9.2', '890'], - ['1.9.3', '1063'], - ['1.9.4', '1196'], - ['1.9.5', '1421'], - ['1.9.6', '1657'], - ['1.9.7', '1761'], - ['1.9.8', '1856'], - ['1.9.9', '1917'], - ['1.9.10', '2003'], - ['1.9.11', '2039'], - ['1.9.12', '2063'], - ['2.0', '2118'], - ['2.0.1', '?'], - ['2.0.2', '?'], - ['2.0.3', '?'], - ['2.1.0', '2119'] -] +BLACK_LISTED_TAGS = '2.2.2', 'help' class TestBzrTags(TestCase): @@ -70,9 +49,11 @@ class TestBzrTags(TestCase): tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.splitlines()) + lines = (line.decode('utf-8') for line in stdout.split()) for line in lines: - tags.append(line.split()) + tags.append(line) - # THEN the tags should match the accepted tags - self.assertEqual(TAGS, tags, 'List of tags should match') + # THEN none of the tags should match the black listed tags + for BLACK_LISTED_TAG in BLACK_LISTED_TAGS: + for tag in tags: + self.assertNotEqual(BLACK_LISTED_TAG, tag, 'Tag should not exist') From c751a208f91d3c8cd74bcc26b08af3737cfb6f57 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:47:41 -0400 Subject: [PATCH 3/4] Change back to using a white list. --- tests/utils/test_bzr_tags.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index e9b6b35bc..0bcc73b54 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -34,7 +34,26 @@ from unittest import TestCase from subprocess import Popen, PIPE -BLACK_LISTED_TAGS = '2.2.2', 'help' +TAGS = [ + ['1.9.0', '1'], + ['1.9.1', '775'], + ['1.9.2', '890'], + ['1.9.3', '1063'], + ['1.9.4', '1196'], + ['1.9.5', '1421'], + ['1.9.6', '1657'], + ['1.9.7', '1761'], + ['1.9.8', '1856'], + ['1.9.9', '1917'], + ['1.9.10', '2003'], + ['1.9.11', '2039'], + ['1.9.12', '2063'], + ['2.0', '2118'], + ['2.0.1', '?'], + ['2.0.2', '?'], + ['2.0.3', '?'], + ['2.1.0', '2119'] +] class TestBzrTags(TestCase): @@ -49,11 +68,9 @@ class TestBzrTags(TestCase): tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.split()) + lines = (line.decode('utf-8') for line in stdout.splitlines()) for line in lines: - tags.append(line) + tags.append(line.split()) - # THEN none of the tags should match the black listed tags - for BLACK_LISTED_TAG in BLACK_LISTED_TAGS: - for tag in tags: - self.assertNotEqual(BLACK_LISTED_TAG, tag, 'Tag should not exist') + # THEN the tags should match the accepted tags + self.assertEqual(TAGS, tags, 'List of tags should match') From d3526c6204ee9a11b77cb4a0f74f2c96c70ed4a0 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 7 Apr 2014 13:22:12 -0400 Subject: [PATCH 4/4] Simplify code per Andreas Preikschat's comment. --- tests/utils/test_bzr_tags.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 0bcc73b54..7bb38f4ab 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -65,12 +65,9 @@ class TestBzrTags(TestCase): # GIVEN: A bzr branch # WHEN getting the branches tags - tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.splitlines()) - for line in lines: - tags.append(line.split()) + tags = [line.decode('utf-8').split() for line in stdout.splitlines()] # THEN the tags should match the accepted tags self.assertEqual(TAGS, tags, 'List of tags should match')