Fix unit tests for OSX
Some unit tests were doing some not-so-unit things and actually reaching out to OS / files for things. This leads to failures when running tests on OSX or other distributions. Change-Id: Iff2cb4d2742a5fd8a5cf4f1bea0ab08504f46016
This commit is contained in:
parent
0b0658d249
commit
b698e7f55e
|
@ -64,20 +64,6 @@ class TestAmphoraInfo(base.TestCase):
|
|||
self.assertEqual(1, result)
|
||||
|
||||
def test__get_meminfo(self):
|
||||
|
||||
# Test live data from host
|
||||
|
||||
result = self.amp_info._get_meminfo()
|
||||
|
||||
# check that /proc/meminfo is giving us the fields we use
|
||||
self.assertIn('MemTotal', result)
|
||||
self.assertIn('MemFree', result)
|
||||
self.assertIn('Buffers', result)
|
||||
self.assertIn('Cached', result)
|
||||
self.assertIn('SwapCached', result)
|
||||
self.assertIn('Shmem', result)
|
||||
self.assertIn('Slab', result)
|
||||
|
||||
# Known data test
|
||||
meminfo = ('MemTotal: 21692784 kB\n'
|
||||
'MemFree: 12685624 kB\n'
|
||||
|
|
|
@ -34,6 +34,8 @@ class ListenerTestCase(base.TestCase):
|
|||
self.jinja_cfg = jinja_cfg.JinjaTemplater(
|
||||
base_amp_path=BASE_AMP_PATH,
|
||||
base_crt_dir=BASE_CRT_PATH)
|
||||
self.mock_platform = mock.patch("platform.linux_distribution").start()
|
||||
self.mock_platform.return_value = ("Ubuntu",)
|
||||
self.test_listener = listener.Listener()
|
||||
|
||||
def test_parse_haproxy_config(self):
|
||||
|
|
|
@ -37,6 +37,8 @@ class TestPlug(base.TestCase):
|
|||
def setUp(self):
|
||||
super(TestPlug, self).setUp()
|
||||
self.mock_netifaces = mock.patch.object(plug, "netifaces").start()
|
||||
self.mock_platform = mock.patch("platform.linux_distribution").start()
|
||||
self.mock_platform.return_value = ("Ubuntu",)
|
||||
self.osutil = osutils.BaseOS.get_os_util()
|
||||
self.test_plug = plug.Plug(self.osutil)
|
||||
self.addCleanup(self.mock_netifaces.stop)
|
||||
|
@ -157,6 +159,8 @@ class TestPlug(base.TestCase):
|
|||
class TestPlugNetwork(base.TestCase):
|
||||
def setUp(self):
|
||||
super(TestPlugNetwork, self).setUp()
|
||||
self.mock_platform = mock.patch("platform.linux_distribution").start()
|
||||
self.mock_platform.return_value = ("Ubuntu",)
|
||||
self.osutil = osutils.BaseOS.get_os_util()
|
||||
self.test_plug = plug.Plug(self.osutil)
|
||||
|
||||
|
|
Loading…
Reference in New Issue