summaryrefslogtreecommitdiffhomepage
path: root/tests/19_test_gbp_scripts_config.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-04-01 20:29:22 +0200
committerGuido Günther <agx@sigxcpu.org>2014-04-01 22:42:13 +0200
commit4c6b06773876a35f55f8f5667af65a917f823757 (patch)
tree8623bdccf7d7d1a0d559bdb8f38dae4af0e652f0 /tests/19_test_gbp_scripts_config.py
parent03ada72d54480917c75e05568844e3f596e2cb64 (diff)
Add minimal 'config' command
This only allows to print single config values so far. Closes: #733470
Diffstat (limited to 'tests/19_test_gbp_scripts_config.py')
-rw-r--r--tests/19_test_gbp_scripts_config.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/19_test_gbp_scripts_config.py b/tests/19_test_gbp_scripts_config.py
new file mode 100644
index 00000000..1c3369bd
--- /dev/null
+++ b/tests/19_test_gbp_scripts_config.py
@@ -0,0 +1,56 @@
+# vim: set fileencoding=utf-8 :
+# (C) 2014 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""Test L{gbp} config"""
+
+import os
+import sys
+import unittest
+import gbp.scripts.config
+
+class TestGbpConfigCommand(unittest.TestCase):
+
+ def setUp(self):
+ self.conffiles_save = os.environ.get('GBP_CONF_FILES')
+ self.confname = 'tests/data/gbp_config.conf'
+ self.assertTrue(os.stat(self.confname))
+ os.environ['GBP_CONF_FILES'] = self.confname
+
+ def test_invocation_single_value(self):
+ """Test if we an invoke it without error"""
+ ret = gbp.scripts.config.main(['doesnotmatter', 'coolcommand.branchname'])
+ self.assertEqual(ret, 0)
+
+ def test_invocation_missing_value(self):
+ """Test if we an invoke it without error"""
+ ret = gbp.scripts.config.main(['doesnotmatter', 'coolcommand.doesnotexist'])
+ self.assertEqual(ret, 1)
+
+ def test_invocation_parse_error(self):
+ """Test if we an invoke it without error"""
+ ret = gbp.scripts.config.main(['doesnotmatter', 'mustcontaindot'])
+ self.assertEqual(ret, 2)
+
+ def test_print_single_value(self):
+ class Printstub(object):
+ result = None
+ def __call__(self, arg):
+ self.result = arg
+
+ printstub = Printstub()
+ ret = gbp.scripts.config.print_single_value('coolcommand.branchname', printstub)
+ self.assertEqual(printstub.result, 'abranch')
+ self.assertEqual(ret, 0)
+