From 94c9e18d55cedc0f443ad13d1af6f9f833d38830 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Thu, 23 Feb 2017 07:14:33 +0000
Subject: [PATCH] Task #10339: try import, skip test if package not available.
 package mock is required for build, just for run.

---
 SAS/MoM/MoMQueryService/test/CMakeLists.txt    |  2 +-
 .../test/test_momqueryservice.py               | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/SAS/MoM/MoMQueryService/test/CMakeLists.txt b/SAS/MoM/MoMQueryService/test/CMakeLists.txt
index d48ea94dc15..adbd82c7175 100644
--- a/SAS/MoM/MoMQueryService/test/CMakeLists.txt
+++ b/SAS/MoM/MoMQueryService/test/CMakeLists.txt
@@ -2,7 +2,7 @@
 include(LofarCTest)
 include(FindPythonModule)
 
-find_python_module(mock REQUIRED)
+find_python_module(mock)
 
 lofar_add_test(test_momqueryservice)
 
diff --git a/SAS/MoM/MoMQueryService/test/test_momqueryservice.py b/SAS/MoM/MoMQueryService/test/test_momqueryservice.py
index 96bda515699..3d75d79eb2e 100755
--- a/SAS/MoM/MoMQueryService/test/test_momqueryservice.py
+++ b/SAS/MoM/MoMQueryService/test/test_momqueryservice.py
@@ -19,11 +19,23 @@
 
 # $Id:  $
 import unittest
-import mock
-import testing.mysqld
 import uuid
 from mysql import connector
 
+try:
+    import mock
+except ImportError as e:
+    print str(e)
+    print 'Please install python package mock: sudo apt-get install python-mock'
+    exit(3) #special lofar test exit code: skipped test
+
+try:
+    import testing.mysqld
+except ImportError as e:
+    print str(e)
+    print 'Please install python package testing.mysqld: sudo pip install testing.mysqld'
+    exit(3) #special lofar test exit code: skipped test
+
 from lofar.common.dbcredentials import Credentials
 from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC
 from lofar.mom.momqueryservice.config import DEFAULT_MOMQUERY_SERVICENAME
@@ -1033,4 +1045,4 @@ class IntegrationTestMoMDatabaseWrapper(unittest.TestCase):
 
 
 if __name__ == "__main__":
-    unittest.main()
\ No newline at end of file
+    unittest.main()
-- 
GitLab