def test_install_user_exists_absolute_homedir(self):
    self.patch('zaza.utilities.installers.user_directory', name='mock_user_directory')
    self.mock_user_directory.return_value = '/some/dir'
    self.patch('zaza.utilities.installers.user_exists', name='mock_user_exists')
    self.patch('zaza.utilities.installers.create_user', name='mock_create_user')
    self.mock_create_user.return_value = '/home/conncheck'
    self.patch('zaza.utilities.installers.install_module_in_venv', name='mock_install_module_in_venv')
    self.patch('zaza.utilities.installers.SystemdControl', name='mock_SystemdControl')
    mock__systemd = mock.Mock()
    self.mock_SystemdControl.return_value = mock__systemd
    self.c._ssh_fn = 'ssh-fn'
    self.c._scp_fn = 'scp-fn'
    self.mock_user_exists.return_value = True
    self.c.install_dir = '/fixed'
    self.c.install()
    self.mock_user_exists.assert_called_once_with('ssh-fn', 'conncheck')
    self.mock_create_user.assert_not_called()
    self.mock_install_module_in_venv.assert_called_once_with('/some/source', '/fixed', 'scp-fn', 'ssh-fn', run_user='conncheck')
    mock__systemd.install.assert_called_once_with()
    self.assertTrue(self.c._installed)
def test_install_user_exists_absolute_homedir(self):
    self.patch('zaza.utilities.installers.user_directory', name='mock_user_directory')
    self.mock_user_directory.return_value = '/some/dir'
    self.patch('zaza.utilities.installers.user_exists', name='mock_user_exists')
    self.patch('zaza.utilities.installers.create_user', name='mock_create_user')
    self.mock_create_user.return_value = '/home/conncheck'
    self.patch('zaza.utilities.installers.install_module_in_venv', name='mock_install_module_in_venv')
    self.patch('zaza.utilities.installers.SystemdControl', name='mock_SystemdControl')
    mock__systemd = mock.Mock()
    self.mock_SystemdControl.return_value = mock__systemd
    self.c._ssh_fn = 'ssh-fn'
    self.c._scp_fn = 'scp-fn'
    self.mock_user_exists.return_value = True
    self.c.install_dir = '/fixed'
    self.c.install()
    self.mock_user_exists.assert_called_once_with('ssh-fn', 'conncheck')
    self.mock_create_user.assert_not_called()
    self.mock_install_module_in_venv.assert_called_once_with('/some/source', '/fixed', 'scp-fn', 'ssh-fn', run_user='conncheck')
    mock__systemd.install.assert_called_once_with()
    self.assertTrue(self.c._installed)