def test_legacy_unentitle_fails_gracefully(self, mock_server): rhn_config = { "systemIdPath": "/some/path", } self.engine.rhncfg = rhn_config self.engine.disable_yum_rhn_plugin = MagicMock(side_effect=IOError) with open_mock("contents") as f: self.engine.legacy_unentitle(mock_server) f.assert_called_once_with("/some/path", "r") mock_server.system.unentitle.assert_called_once_with("contents")
def test_legacy_unentitle(self, mock_server): rhn_config = { "systemIdPath": "/some/path", } self.engine.rhncfg = rhn_config self.engine.disable_yum_rhn_plugin = MagicMock(return_value=True) with open_mock("contents") as f: self.engine.legacy_unentitle(mock_server) f.assert_called_once_with("/some/path", "r") mock_server.system.unentitle.assert_called_once_with("contents")
def test_load_transition_data(self, mock_server): rhn_config = { "systemIdPath": "/some/path", } self.engine.rhncfg = rhn_config mock_server.system.transitionDataForSystem.return_value = {"uuid": "1"} with open_mock("contents") as f: self.engine.load_transition_data(mock_server) f.assert_called_once_with("/some/path", "r") mock_server.system.transitionDataForSystem.assert_called_once_with("contents") self.assertEquals("1", self.engine.consumer_id)
def test_load_transition_data(self, mock_server): rhn_config = { "systemIdPath": "/some/path", } self.engine.rhncfg = rhn_config mock_server.system.transitionDataForSystem.return_value = {"uuid": "1"} with open_mock("contents") as f: self.engine.load_transition_data(mock_server) f.assert_called_once_with("/some/path", "r") mock_server.system.transitionDataForSystem.assert_called_once_with( "contents") self.assertEquals("1", self.engine.consumer_id)
def test_get_system_id(self): rhn_config = { "systemIdPath": "/tmp/foo", } mock_file = """ <params> <param> <value> <struct> <member> <name>system_id</name> <value> <string>ID-123</string> </value> </member> </struct> </value> </param> </params> """ self.engine.rhncfg = rhn_config with open_mock(mock_file) as m: system_id = self.engine.get_system_id(m) self.assertEquals(123, system_id)