def test_install_drivers_rejects_invalid_config( self, m_debconf, cfg_accepted, install_gpgpu ): """install_drivers should raise TypeError if not given a config dict""" pkg_install = mock.MagicMock() with pytest.raises(TypeError, match=".*expected dict.*"): drivers.install_drivers("mystring", pkg_install_func=pkg_install) assert 0 == pkg_install.call_count
def test_install_drivers_no_install_if_present(self, m_which, m_subp): """If 'ubuntu-drivers' is present, no package install should occur.""" pkg_install = mock.MagicMock() drivers.install_drivers(self.cfg_accepted['drivers'], pkg_install_func=pkg_install) self.assertEqual(0, pkg_install.call_count) self.assertEqual([mock.call('ubuntu-drivers')], m_which.call_args_list) self.assertEqual([mock.call(self.install_gpgpu)], m_subp.call_args_list)
def test_install_drivers_no_install_if_present(self, m_which, m_subp): """If 'ubuntu-drivers' is present, no package install should occur.""" pkg_install = mock.MagicMock() drivers.install_drivers(self.cfg_accepted['drivers'], pkg_install_func=pkg_install) self.assertEqual(0, pkg_install.call_count) self.assertEqual([mock.call('ubuntu-drivers')], m_which.call_args_list) self.assertEqual([mock.call(self.install_gpgpu)], m_subp.call_args_list)
def test_install_drivers_no_install_if_present(self, m_which, m_subp, m_tmp): """If 'ubuntu-drivers' is present, no package install should occur.""" tdir = self.tmp_dir() debconf_file = os.path.join(tdir, 'nvidia.template') m_tmp.return_value = tdir pkg_install = mock.MagicMock() drivers.install_drivers(self.cfg_accepted['drivers'], pkg_install_func=pkg_install) self.assertEqual(0, pkg_install.call_count) self.assertEqual([mock.call('ubuntu-drivers')], m_which.call_args_list) self.assertEqual([ mock.call(AnyTempScriptAndDebconfFile(tdir, debconf_file)), mock.call(self.install_gpgpu) ], m_subp.call_args_list)
def test_install_drivers_no_install_if_present( self, m_which, m_subp, m_tmp, m_debconf, tmpdir, cfg_accepted, install_gpgpu, ): """If 'ubuntu-drivers' is present, no package install should occur.""" tdir = tmpdir debconf_file = tmpdir.join("nvidia.template") m_tmp.return_value = tdir pkg_install = mock.MagicMock() drivers.install_drivers( cfg_accepted["drivers"], pkg_install_func=pkg_install ) assert 0 == pkg_install.call_count assert [mock.call("ubuntu-drivers")] == m_which.call_args_list assert [ mock.call(drivers.X_LOADTEMPLATEFILE, debconf_file) ] == m_debconf.DebconfCommunicator().__enter__().command.call_args_list assert [mock.call(install_gpgpu)] == m_subp.call_args_list
def test_install_drivers_rejects_invalid_config(self): """install_drivers should raise TypeError if not given a config dict""" pkg_install = mock.MagicMock() with self.assertRaisesRegex(TypeError, ".*expected dict.*"): drivers.install_drivers("mystring", pkg_install_func=pkg_install) self.assertEqual(0, pkg_install.call_count)
def test_install_drivers_rejects_invalid_config(self): """install_drivers should raise TypeError if not given a config dict""" pkg_install = mock.MagicMock() with self.assertRaisesRegex(TypeError, ".*expected dict.*"): drivers.install_drivers("mystring", pkg_install_func=pkg_install) self.assertEqual(0, pkg_install.call_count)