#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-

import base
import ldtp
import os

# 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'
	base.quit()
	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/'
	base.quit()
	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'
	base.quit()
	return rv

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

