From 107c9a1b521ca814db10c1d21029d72d999f26cb Mon Sep 17 00:00:00 2001 From: Benjamin Hoving Date: Wed, 18 Sep 2019 11:34:55 -0400 Subject: [PATCH 1/4] git tag tests --- tests/utils/test_bzr_tags.py | 45 ++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 6e3f5906a..6a73a0010 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -32,21 +32,48 @@ TAGS1 = {'1.9.0', '1.9.1', '1.9.2', '1.9.3', '1.9.4', '1.9.5', '1.9.6', '1.9.7', '2.3.1', '2.3.2', '2.3.3', '2.4'} -class TestBzrTags(TestCase): +# class TestBzrTags(TestCase): - def test_bzr_tags(self): +# def test_bzr_tags(self): +# """ +# Test for proper bzr tags +# """ +# # GIVEN: A bzr branch +# path = os.path.dirname(__file__) + +# # WHEN getting the branches tags +# try: +# bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE) +# except Exception: +# raise SkipTest('bzr is not installed') +# std_out = bzr.communicate()[0] +# count = len(TAGS1) +# tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] +# count1 = 0 +# for t in tags: +# if t in TAGS1: +# count1 += 1 + +# # THEN the tags should match the accepted tags +# assert count == count1, 'List of tags should match' + + +class TestGitTags(TestCase): + def test_git_tags(self): """ - Test for proper bzr tags + Test for proper git tags """ - # GIVEN: A bzr branch + # GIVEN: a git repo path = os.path.dirname(__file__) - # WHEN getting the branches tags + # WHEN: getting the tags try: - bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE) + git = Popen(('git', 'tags'), stdout=PIPE) except Exception: - raise SkipTest('bzr is not installed') + raise SkipTest('git is not installed') + std_out = bzr.communicate()[0] + count = len(TAGS1) tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] count1 = 0 @@ -54,5 +81,5 @@ class TestBzrTags(TestCase): if t in TAGS1: count1 += 1 - # THEN the tags should match the accepted tags - assert count == count1, 'List of tags should match' + # THEN: the tags should match the accepted tags + assert count == count1 From c68a28e5398332077ac7d20b70e156182097b0c9 Mon Sep 17 00:00:00 2001 From: Benjamin Hoving Date: Wed, 18 Sep 2019 11:51:17 -0400 Subject: [PATCH 2/4] typo and remove historyboxcombo test file --- .../ui/lib/test_historycombobox.py | 64 ------------------- .../{test_bzr_tags.py => test_git_tags.py} | 4 +- 2 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 tests/interfaces/openlp_core/ui/lib/test_historycombobox.py rename tests/utils/{test_bzr_tags.py => test_git_tags.py} (97%) diff --git a/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py b/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py deleted file mode 100644 index 96c835398..000000000 --- a/tests/interfaces/openlp_core/ui/lib/test_historycombobox.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2017 OpenLP Developers # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### -""" -Module to test the :mod:`~openlp.core.common.historycombobox` module. -""" - -from unittest import TestCase - -from PyQt5 import QtWidgets - -from openlp.core.common.registry import Registry -from openlp.core.ui.lib.historycombobox import HistoryComboBox -from tests.helpers.testmixin import TestMixin - - -class TestHistoryComboBox(TestCase, TestMixin): - def setUp(self): - """ - Some pre-test setup required. - """ - Registry.create() - self.setup_application() - self.main_window = QtWidgets.QMainWindow() - Registry().register('main_window', self.main_window) - self.combo = HistoryComboBox(self.main_window) - - def tearDown(self): - """ - Delete all the C++ objects at the end so that we don't have a segfault - """ - del self.combo - del self.main_window - - def test_get_items(self): - """ - Test the getItems() method - """ - # GIVEN: The combo. - - # WHEN: Add two items. - self.combo.addItem('test1') - self.combo.addItem('test2') - - # THEN: The list of items should contain both strings. - self.assertEqual(self.combo.getItems(), ['test1', 'test2']) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_git_tags.py similarity index 97% rename from tests/utils/test_bzr_tags.py rename to tests/utils/test_git_tags.py index 6a73a0010..def579317 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_git_tags.py @@ -68,11 +68,11 @@ class TestGitTags(TestCase): # WHEN: getting the tags try: - git = Popen(('git', 'tags'), stdout=PIPE) + git = Popen(('git', 'tag'), stdout=PIPE) except Exception: raise SkipTest('git is not installed') - std_out = bzr.communicate()[0] + std_out = git.communicate()[0] count = len(TAGS1) tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] From 808ee8ed2df1b60d0ac2e9c39a1d02921ab1dfd4 Mon Sep 17 00:00:00 2001 From: Benjamin Hoving Date: Wed, 18 Sep 2019 13:14:12 -0400 Subject: [PATCH 3/4] cleanup/flake8 --- tests/utils/test_git_tags.py | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/tests/utils/test_git_tags.py b/tests/utils/test_git_tags.py index def579317..fd2719ea9 100644 --- a/tests/utils/test_git_tags.py +++ b/tests/utils/test_git_tags.py @@ -22,7 +22,6 @@ """ Package to test for proper bzr tags. """ -import os from subprocess import PIPE, Popen from unittest import TestCase, SkipTest @@ -32,39 +31,15 @@ TAGS1 = {'1.9.0', '1.9.1', '1.9.2', '1.9.3', '1.9.4', '1.9.5', '1.9.6', '1.9.7', '2.3.1', '2.3.2', '2.3.3', '2.4'} -# class TestBzrTags(TestCase): - -# def test_bzr_tags(self): -# """ -# Test for proper bzr tags -# """ -# # GIVEN: A bzr branch -# path = os.path.dirname(__file__) - -# # WHEN getting the branches tags -# try: -# bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE) -# except Exception: -# raise SkipTest('bzr is not installed') -# std_out = bzr.communicate()[0] -# count = len(TAGS1) -# tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] -# count1 = 0 -# for t in tags: -# if t in TAGS1: -# count1 += 1 - -# # THEN the tags should match the accepted tags -# assert count == count1, 'List of tags should match' - - class TestGitTags(TestCase): def test_git_tags(self): """ Test for proper git tags """ # GIVEN: a git repo - path = os.path.dirname(__file__) + + # pyflake complains about this line because the value of path is never used + # path = os.path.dirname(__file__) # WHEN: getting the tags try: From f3f0f6404ee9cef40da1ff5bc960a003c13b9d5c Mon Sep 17 00:00:00 2001 From: Benjamin Hoving Date: Wed, 18 Sep 2019 18:09:49 -0400 Subject: [PATCH 4/4] delete test_git_tags (test_bzr_tags) --- tests/utils/test_git_tags.py | 60 ------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 tests/utils/test_git_tags.py diff --git a/tests/utils/test_git_tags.py b/tests/utils/test_git_tags.py deleted file mode 100644 index fd2719ea9..000000000 --- a/tests/utils/test_git_tags.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -########################################################################## -# OpenLP - Open Source Lyrics Projection # -# ---------------------------------------------------------------------- # -# Copyright (c) 2008-2019 OpenLP Developers # -# ---------------------------------------------------------------------- # -# 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, either version 3 of the License, or # -# (at your option) any later version. # -# # -# 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, see . # -########################################################################## -""" -Package to test for proper bzr tags. -""" -from subprocess import PIPE, Popen -from unittest import TestCase, SkipTest - - -TAGS1 = {'1.9.0', '1.9.1', '1.9.2', '1.9.3', '1.9.4', '1.9.5', '1.9.6', '1.9.7', '1.9.8', '1.9.9', '1.9.10', - '1.9.11', '1.9.12', '2.0', '2.1.0', '2.1.1', '2.1.2', '2.1.3', '2.1.4', '2.1.5', '2.1.6', '2.2', - '2.3.1', '2.3.2', '2.3.3', '2.4'} - - -class TestGitTags(TestCase): - def test_git_tags(self): - """ - Test for proper git tags - """ - # GIVEN: a git repo - - # pyflake complains about this line because the value of path is never used - # path = os.path.dirname(__file__) - - # WHEN: getting the tags - try: - git = Popen(('git', 'tag'), stdout=PIPE) - except Exception: - raise SkipTest('git is not installed') - - std_out = git.communicate()[0] - - count = len(TAGS1) - tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] - count1 = 0 - for t in tags: - if t in TAGS1: - count1 += 1 - - # THEN: the tags should match the accepted tags - assert count == count1