aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-12-09 11:38:27 +0100
committerGuido Günther <agx@sigxcpu.org>2016-12-09 12:31:23 +0100
commitef1d8e7250776a282eec3183d413141448a7be2f (patch)
treed75ea95b91fead9606b70a1175866411e9d6442e /tests
parenta75955f0a243c8359d556b4927cb310472986480 (diff)
create_remote_repo: allow to list config sections
Diffstat (limited to 'tests')
-rw-r--r--tests/27_test_create_remote_repo.py47
-rw-r--r--tests/data/gbp_create_remote_repo.conf8
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/27_test_create_remote_repo.py b/tests/27_test_create_remote_repo.py
new file mode 100644
index 0000000..7ab3c51
--- /dev/null
+++ b/tests/27_test_create_remote_repo.py
@@ -0,0 +1,47 @@
+# vim: set fileencoding=utf-8 :
+# (C) 2016 Guido Günther <agx@sigxcpu.org>
+# 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 2 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, please see
+# <http://www.gnu.org/licenses/>
+"""Test the L{gbp} create_remote_repo command"""
+
+import os
+import unittest
+import gbp.scripts.create_remote_repo as create_remote_repo
+
+
+class TestGbpCreateRemoteRepoCommand(unittest.TestCase):
+ def setUp(self):
+ self.conffiles_save = os.environ.get('GBP_CONF_FILES')
+
+ def tearDown(self):
+ if self.conffiles_save:
+ os.environ['GBP_CONF_FILES'] = self.conffiles_save
+
+ def test_no_config_templates(self):
+ self.confname = 'tests/data/gbp_nonexistent.conf'
+ self.assertFalse(os.path.exists(self.confname))
+ os.environ['GBP_CONF_FILES'] = self.confname
+
+ _, _, sections = create_remote_repo.parse_args(['create-remote-repo'])
+ self.assertEqual(create_remote_repo.get_config_names(sections),
+ [])
+
+ def test_list_config_templates(self):
+ self.confname = 'tests/data/gbp_create_remote_repo.conf'
+ self.assertTrue(os.path.exists(self.confname))
+ os.environ['GBP_CONF_FILES'] = self.confname
+
+ _, _, sections = create_remote_repo.parse_args(['create-remote-repo'])
+ self.assertEqual(create_remote_repo.get_config_names(sections),
+ ['config1', 'config2'])
diff --git a/tests/data/gbp_create_remote_repo.conf b/tests/data/gbp_create_remote_repo.conf
new file mode 100644
index 0000000..15c440d
--- /dev/null
+++ b/tests/data/gbp_create_remote_repo.conf
@@ -0,0 +1,8 @@
+# Data for TestGbpCreateRemoteRepo
+
+[remote-config config1]]
+remote-url-pattern = ssh://git.debian.org/git/pkg-libvirt/%(pkg)s.git
+template-dir = /srv/alioth.debian.org/chroot/home/groups/pkg-libvirt/git-template
+
+[remote-config config2]
+remote-url-pattern = ssh://git.debian.org/git/calendarserver/%(pkg)s.git