From e4f71ada86ee4a42287cf401b77d48c9f98ca5aa Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Tue, 15 Sep 2015 22:32:45 +0000 Subject: [PATCH] Fix unit tests on non-Red Hat distros We were looking for /etc/redhat-release, which won't work on anything not Red Hat-derived. Such as the gate. :-) Change-Id: I07249a196764aa599788b26417e37b87f4b1bc11 --- .../tests/v1/overcloud_image/test_overcloud_image.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py index b0374c424..031ec1349 100644 --- a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py +++ b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py @@ -13,6 +13,7 @@ # under the License. # +import io import mock import os @@ -39,7 +40,10 @@ class TestOvercloudImageBuild(TestPluginV1): parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.cmd.take_action(parsed_args) + redhat_release = io.StringIO(u'CentOS Fake Release') + with mock.patch('tripleoclient.v1.overcloud_image.open', + return_value=redhat_release, create=True): + self.cmd.take_action(parsed_args) self.assertEqual(2, self.cmd._ramdisk_image_create.call_count) self.assertEqual(1, self.cmd._disk_image_create.call_count)