WIP: Introduce obs-service-gbp-adm command
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 25 Sep 2014 10:03:28 +0000 (13:03 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 25 Sep 2014 10:04:10 +0000 (13:04 +0300)
Change-Id: I82c468f618a5921c3e57af5aafcde2ffb6b5da2a
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
obs_service_gbp/adm.py [new file with mode: 0755]
setup.py
tests/test_repocache_adm.py

diff --git a/obs_service_gbp/adm.py b/obs_service_gbp/adm.py
new file mode 100755 (executable)
index 0000000..2ee05b3
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/python -u
+# vim:fileencoding=utf-8:et:ts=4:sw=4:sts=4
+#
+# Copyright (C) 2013 Intel Corporation <markus.lehtonen@linux.intel.com>
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+"""The repocache-adm tool specific for obs-service-git-buildpackage"""
+
+import sys
+
+from repocache_adm.adm import MainCommand as BaseCommand
+from obs_service_gbp.command import read_config
+
+class MainCommand(BaseCommand):
+    """Class for the command line script"""
+    @staticmethod
+    def add_arguments(parser):
+        """Add arguments"""
+        # Parse config files
+        config = read_config()
+        # Add arguments
+        parser.set_defaults(cache_dir=config['repo-cache-dir'])
+
+
+if __name__ == '__main__':
+    sys.exit(MainCommand.main())
+
+
index 1f16160d8ee3b88681223aa820d61adb71ffcc1c..b7c3766fdc1b69e4145e37b55bed7f6004da6acf 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -43,6 +43,7 @@ setup(name='obs_service_gbp',
                     'service/git-buildpackage.service']),
                   ('/etc/obs/services', ['config/git-buildpackage'])],
       entry_points={
-          'console_scripts': ['repocache-adm = repocache_adm.adm:main']
+          'console_scripts': ['repocache-adm = repocache_adm.adm:main',
+                              'obs-service-gbp-adm = obs_service_gbp.adm']
           }
      )
index 30cf9aa98fe6db12e7102e5b06990b1e6f98bbd9..867272ed9dde307b88d7f3846d70a2ef81bd3b58 100644 (file)
 import mock
 import os
 import shutil
-from nose.tools import assert_raises, eq_  # pylint: disable=E0611
+from nose.tools import assert_raises, eq_, nottest  # pylint: disable=E0611
 
+import obs_service_gbp.adm
+import repocache_adm.adm
 from gbp_repocache import CachedRepo
-from repocache_adm.adm import MainCommand
 from repocache_adm.common import SubcommandBase
 from tests import UnitTestsBase
 
@@ -41,7 +42,7 @@ class BadSubcommand(SubcommandBase):
 class TestRepocacheAdm(UnitTestsBase):
     """Test repocache-adm command line tool"""
 
-    adm = MainCommand.main
+    adm = repocache_adm.adm.MainCommand.main
 
     @classmethod
     def setup_class(cls):
@@ -96,3 +97,14 @@ class TestRepocacheAdm(UnitTestsBase):
         # Non-existent cache dir
         eq_(self.adm(['-c', 'non-existent', 'stat']), 1)
 
+
+class TestGbpRepocacheAdm(TestRepocacheAdm):
+    """Test obs-service-gbp-adm command line tool"""
+
+    adm = obs_service_gbp.adm.MainCommand.main
+
+    @nottest
+    def test_not_implemented(self):
+        """Skip this test"""
+        pass
+