tests: test case for internal service errors
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 30 May 2014 10:36:24 +0000 (13:36 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 2 Jun 2014 12:33:30 +0000 (15:33 +0300)
Change-Id: If52270d8375e3cb2fc4f4198c7a1bdab782651f4
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests/test_obs_service_gbp.py

index 63f3e5ae51dfc85d6c0fd0f4c17ca6e499fe0b89..a7222842649ccc53e7355d1191e4ca729f2dcfcd 100644 (file)
@@ -26,6 +26,7 @@ import stat
 from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
 
 from obs_service_gbp.command import main as service
+from obs_service_gbp_utils import GbpServiceError
 from tests import UnitTestsBase
 
 
@@ -37,6 +38,10 @@ def _mock_gbp():
     """Fake gbp main function for testing"""
     raise FakeGbpError()
 
+def _mock_fork_call(*args, **kwargs):
+    """Fake fork_call function for testing"""
+    raise GbpServiceError("Mock error, args: %s, kwargs: %s" % (args, kwargs))
+
 
 class TestService(UnitTestsBase):
     """Base class for unit tests"""
@@ -108,6 +113,11 @@ class TestService(UnitTestsBase):
         """Test crash in git-buildpackage-rpm"""
         eq_(service(['--url', self.orig_repo.path, '--revision=rpm']), 1)
 
+    @mock.patch('obs_service_gbp.command.fork_call', _mock_fork_call)
+    def test_service_error(self):
+        """Test internal/configuration error"""
+        eq_(service(['--url', self.orig_repo.path]), 1)
+
     def test_options_outdir(self):
         """Test the --outdir option"""
         outdir = os.path.join(self.tmpdir, 'outdir')