#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# © 2008,2009 Michael Terry <mike@mterry.name>
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys
sys.path.insert(0, sys.path[0]+'/..')
import base
import ldtp

# First we test how things work when there's no valid ssh info
def no_values():
	base.setup(start = False)
	base.set_gconf_value('backend', 'ssh')
	base.start_deja_dup()
	rv = base.get_gconf_value('backend') == 'file'
	return rv

# Now test bits and pieces missing
def some_values():
	base.setup(start = False)
	base.set_gconf_value('backend', 'ssh')
	base.set_gconf_value('ssh/server', 'localhost')
	base.start_deja_dup()
	rv = base.get_gconf_value('backend') == 'file' and \
	     base.get_gconf_value('file/path') == 'ssh://localhost/'
	return rv

# Now test everything together
def all_values():
	base.setup(start = False)
	base.set_gconf_value('backend', 'ssh')
	base.set_gconf_value('ssh/server', 'localhost')
	base.set_gconf_value('ssh/port', '42', key_type = 'int')
	base.set_gconf_value('ssh/username', 'goober')
	base.set_gconf_value('ssh/directory', '/hello')
	base.start_deja_dup()
	rv = base.get_gconf_value('backend') == 'file' and \
       base.get_gconf_value('file/path') == 'ssh://goober@localhost:42/hello'
	return rv

base.run(no_values)
base.run(some_values)
base.run(all_values)

