Ondřej Svoboda has uploaded a new change for review. Change subject: net tests: separate a resolv.conf test from NetInfo tests ......................................................................
net tests: separate a resolv.conf test from NetInfo tests Change-Id: I566f3450f849df65e8b0c427ff883d7e6c9223d2 Signed-off-by: Ondřej Svoboda <osvob...@redhat.com> --- M tests/network/netinfo_test.py A tests/network/resolv_test.py 2 files changed, 54 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/62723/1 diff --git a/tests/network/netinfo_test.py b/tests/network/netinfo_test.py index c4d21de..67f82d5 100644 --- a/tests/network/netinfo_test.py +++ b/tests/network/netinfo_test.py @@ -25,7 +25,6 @@ from nose.plugins.attrib import attr from vdsm.network import ipwrapper -from vdsm.network.ip import resolv from vdsm.network.netinfo import addresses, bonding, misc, nics, routes from vdsm.network.netinfo.cache import get from vdsm.utils import random_iface_name @@ -44,27 +43,6 @@ @attr(type='unit') class TestNetinfo(TestCaseBase): - - def testGetHostNameservers(self): - RESOLV_CONF = ( - '# Generated by NetworkManager\n' - 'search example.com company.net\n' - 'domain example.com\n' - 'nameserver 192.168.0.100\n' - 'nameserver 8.8.8.8\n' - 'nameserver 8.8.4.4\n' - ) - nameservers = ['192.168.0.100', '8.8.8.8', '8.8.4.4'] - with namedTemporaryDir() as temp_dir: - file_path = os.path.join(temp_dir, 'resolv.conf') - - with mock.patch.object(resolv, 'DNS_CONF_FILE', file_path): - for content in (RESOLV_CONF, RESOLV_CONF + '\n'): - with open(file_path, 'w') as file_object: - file_object.write(content) - - self.assertEqual(resolv.get_host_nameservers(), - nameservers) def testNetmaskConversions(self): path = os.path.join(os.path.dirname(__file__), "netmaskconversions") diff --git a/tests/network/resolv_test.py b/tests/network/resolv_test.py new file mode 100644 index 0000000..2b734dc --- /dev/null +++ b/tests/network/resolv_test.py @@ -0,0 +1,54 @@ +# +# Copyright 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# +from __future__ import absolute_import +import os + +from nose.plugins.attrib import attr + +from vdsm.network.ip import resolv + +from testlib import mock +from testlib import VdsmTestCase as TestCaseBase, namedTemporaryDir + + +@attr(type='unit') +class ResolvTest(TestCaseBase): + RESOLV_CONF = [ + '# Generated by NetworkManager\n', + 'search example.com company.net\n', + 'domain example.com\n', + 'nameserver 192.168.0.100\n', + 'nameserver 8.8.8.8\n', + 'nameserver 8.8.4.4\n', + ] + + def test_get_host_nameservers(self): + nameservers = ['192.168.0.100', '8.8.8.8', '8.8.4.4'] + with namedTemporaryDir() as temp_dir: + file_path = os.path.join(temp_dir, 'resolv.conf') + + with mock.patch.object(resolv, 'DNS_CONF_FILE', file_path): + for content in (self.RESOLV_CONF, self.RESOLV_CONF + ['\n']): + with open(file_path, 'w') as file_object: + file_object.writelines(content) + + self.assertEqual(resolv.get_host_nameservers(), + nameservers) -- To view, visit https://gerrit.ovirt.org/62723 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I566f3450f849df65e8b0c427ff883d7e6c9223d2 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ondřej Svoboda <osvob...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org