Exemple #1
0
    def test_build_bond(self):
        '''
        Test to create a bond script in /etc/modprobe.d with the passed
        settings and load the bonding kernel module.
        '''
        with patch.dict(rh_ip.__grains__, {'osrelease': 'osrelease'}):
            with patch.object(rh_ip, '_parse_settings_bond', MagicMock()):
                mock = jinja2.exceptions.TemplateNotFound('foo')
                with patch.object(jinja2.Environment, 'get_template',
                                  MagicMock(side_effect=mock)):
                    self.assertEqual(rh_ip.build_bond('iface'), '')

                with patch.dict(rh_ip.__salt__,
                                {'kmod.load': MagicMock(return_value=None)}):
                    with patch.object(rh_ip,
                                      '_write_file_iface',
                                      return_value=None):
                        with patch.object(rh_ip,
                                          '_read_temp',
                                          return_value='A'):
                            self.assertEqual(
                                rh_ip.build_bond('iface', test='A'), 'A')

                        with patch.object(rh_ip,
                                          '_read_file',
                                          return_value='A'):
                            self.assertEqual(
                                rh_ip.build_bond('iface', test=None), 'A')
Exemple #2
0
    def test_build_bond(self):
        """
        Test to create a bond script in /etc/modprobe.d with the passed
        settings and load the bonding kernel module.
        """
        with patch.dict(rh_ip.__grains__, {"osrelease": "osrelease"}):
            with patch.object(rh_ip, "_parse_settings_bond", MagicMock()):
                mock = jinja2.exceptions.TemplateNotFound("foo")
                with patch.object(jinja2.Environment, "get_template",
                                  MagicMock(side_effect=mock)):
                    self.assertEqual(rh_ip.build_bond("iface"), "")

                with patch.dict(rh_ip.__salt__,
                                {"kmod.load": MagicMock(return_value=None)}):
                    with patch.object(rh_ip,
                                      "_write_file_iface",
                                      return_value=None):
                        with patch.object(rh_ip,
                                          "_read_temp",
                                          return_value="A"):
                            self.assertEqual(
                                rh_ip.build_bond("iface", test="A"), "A")

                        with patch.object(rh_ip,
                                          "_read_file",
                                          return_value="A"):
                            self.assertEqual(
                                rh_ip.build_bond("iface", test=None), "A")
Exemple #3
0
    def test_build_bond(self):
        '''
        Test to create a bond script in /etc/modprobe.d with the passed
        settings and load the bonding kernel module.
        '''
        with patch.dict(rh_ip.__grains__, {'osrelease': 'osrelease'}):
            with patch.object(rh_ip, '_parse_settings_bond', MagicMock()):
                mock = jinja2.exceptions.TemplateNotFound('foo')
                with patch.object(jinja2.Environment, 'get_template',
                                  MagicMock(side_effect=mock)):
                    self.assertEqual(rh_ip.build_bond('iface'), '')

                with patch.dict(rh_ip.__salt__, {'kmod.load':
                                                 MagicMock(return_value=None)}):
                    with patch.object(rh_ip, '_write_file_iface',
                                      return_value=None):
                        with patch.object(rh_ip, '_read_temp', return_value='A'):
                            self.assertEqual(rh_ip.build_bond('iface', test='A'),
                                             'A')

                        with patch.object(rh_ip, '_read_file', return_value='A'):
                            self.assertEqual(rh_ip.build_bond('iface', test=None),
                                             'A')