Signed-off-by: Lucio Correia <
luci...@linux.vnet.ibm.com>
---
tests/test_audisp_plugins.py | 5 ++++-
tests/test_auditdisp.py | 11 ++++++-----
tests/test_partitions.py | 5 ++++-
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/tests/test_audisp_plugins.py b/tests/test_audisp_plugins.py
index b36c950..b81004c 100644
--- a/tests/test_audisp_plugins.py
+++ b/tests/test_audisp_plugins.py
@@ -1,7 +1,7 @@
#
# Project Ginger
#
-# Copyright IBM Corp, 2016
+# Copyright IBM Corp, 2016-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -20,6 +20,8 @@
import mock
import unittest
+import tests.utils as utils
+
from wok.exception import NotFoundError
from wok.plugins.ginger.model.audisp_plugins import PluginsModel, write_to_conf
from wok.plugins.ginger.model.audisp_plugins import PluginModel
@@ -41,6 +43,7 @@ class Audisp_PluginsTests(unittest.TestCase):
out = audisp_plugins.get_list()
self.assertIn(plugin, out)
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_get_list_invalid_plugin(self):
"""
Unittest to test invalid plugin in list of plugins.
diff --git a/tests/test_auditdisp.py b/tests/test_auditdisp.py
index 0b49bec..cda9cbc 100644
--- a/tests/test_auditdisp.py
+++ b/tests/test_auditdisp.py
@@ -1,7 +1,7 @@
#
# Project Ginger
#
-# Copyright IBM Corp, 2016
+# Copyright IBM Corp, 2016-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,8 @@ import unittest
from wok.plugins.ginger.model.utils import write_to_conf
from wok.plugins.ginger.model.auditdisp import AuditdispModel
+import tests.utils as utils
+
class AuditdispTests(unittest.TestCase):
@@ -67,10 +69,9 @@ class AuditdispTests(unittest.TestCase):
mock_write.return_value = {}
write_to_conf(key, value, AUDISPD_CONF)
- @mock.patch('wok.plugins.ginger.model.'
- 'utils.del_lines_of_attribute')
- @mock.patch('wok.plugins.ginger.model.'
- 'utils.write_to_conf')
+ @mock.patch('wok.plugins.ginger.model.auditdisp.del_lines_of_attribute')
+ @mock.patch('wok.plugins.ginger.model.auditdisp.write_to_conf')
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_update(self, mock_write, mock_del):
"""
Unit test to update data to audisp conf file.
diff --git a/tests/test_partitions.py b/tests/test_partitions.py
index 31b1b1a..c79e09e 100644
--- a/tests/test_partitions.py
+++ b/tests/test_partitions.py
@@ -1,7 +1,7 @@
#
# Project Ginger
#
-# Copyright IBM Corp, 2015-2016
+# Copyright IBM Corp, 2015-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,8 @@ import mock
import unittest
import wok.plugins.ginger.model.diskparts as diskparts
+import tests.utils as utils
+
from wok import config
from wok.exception import MissingParameter, NotFoundError
from wok.model.tasks import TaskModel
@@ -33,6 +35,7 @@ class PartitionTests(unittest.TestCase):
self._objstore = ObjectStore(objstore_loc)
self.task_model = TaskModel(objstore=self._objstore)
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_get_part_list(self):
parts = diskparts.PartitionsModel()
parts_list = parts.get_list()
--
2.7.4