def test_build_bond_data(self): ''' Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. ''' mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {'osrelease': mock}): self.assertTrue(debian_ip.build_bond('bond0', test='True'))
def test_build_bond_exception(self): ''' Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. ''' mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {'osrelease': mock}): mock = MagicMock( side_effect=jinja2.exceptions.TemplateNotFound('error')) with patch.object(jinja2.Environment, 'get_template', mock): self.assertEqual(debian_ip.build_bond('bond0'), '')
def test_build_bond_exception(self): ''' Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. ''' mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {'osrelease': mock}): mock = MagicMock(side_effect= jinja2.exceptions.TemplateNotFound('error')) with patch.object(jinja2.Environment, 'get_template', mock): self.assertEqual(debian_ip.build_bond('bond0'), '')
def test_build_bond(self): ''' Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. ''' mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {'osrelease': mock}): mock = MagicMock(return_value=True) with patch.dict(debian_ip.__salt__, {'kmod.load': mock, 'pkg.install': mock}): self.assertEqual(debian_ip.build_bond('bond0'), '')
def test_build_bond_data(self): """ Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. """ with patch("salt.modules.debian_ip._parse_settings_bond", MagicMock(return_value={})), patch( "salt.modules.debian_ip._read_temp", MagicMock(return_value=True)): mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {"osrelease": mock}): self.assertTrue(debian_ip.build_bond("bond0", test="True"))
def test_build_bond_exception(self): """ Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. """ with patch("salt.modules.debian_ip._parse_settings_bond", MagicMock(return_value={})): mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {"osrelease": mock}): mock = MagicMock( side_effect=jinja2.exceptions.TemplateNotFound("error")) with patch.object(jinja2.Environment, "get_template", mock): self.assertEqual(debian_ip.build_bond("bond0"), "")
def test_build_bond(self): """ Test if it create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module. """ with patch("salt.modules.debian_ip._parse_settings_bond", MagicMock(return_value={})), patch( "salt.modules.debian_ip._write_file", MagicMock(return_value=True)): mock = MagicMock(return_value=1) with patch.dict(debian_ip.__grains__, {"osrelease": mock}): mock = MagicMock(return_value=True) with patch.dict(debian_ip.__salt__, { "kmod.load": mock, "pkg.install": mock }): self.assertEqual(debian_ip.build_bond("bond0"), "")