'Unregister an host, check that result is changed'

@patch('os.unlink')
def test_unregister(self, mock_unlink):

    mock_unlink.return_value = True
    set_module_args({'activationkey': 'key', 'username': 'user', 'password': 'pass', 'state': 'absent'})
    responses = [('auth.login', [('X' * 43)]), ('system.deleteSystems', [1]), ('auth.logout', [1])]
    with patch.object(basic.AnsibleModule, 'run_command') as run_command:
        run_command.return_value = (0, '', '')
        mock_is_registered = PropertyMock(return_value=True)
        mock_systemid = PropertyMock(return_value=12345)
        with patch.multiple(rhn_register.Rhn, systemid=mock_systemid, is_registered=mock_is_registered):
            with mock_request(responses):
                with self.assertRaises(AnsibleExitJson) as result:
                    self.module.main()
                self.assertTrue(result.exception.args[0]['changed'])
            self.assertFalse(responses)
        self.assertEqual(mock_systemid.call_count, 1)
        self.assertEqual(mock_is_registered.call_count, 1)
    self.assertFalse(run_command.called)
    self.assertEqual(mock_unlink.call_count, 1)
