
import os, tempfile, yaml, ConfigParser
from .. import no_you_talk_to_the_hand as ny


testcfg = {
    'tunnels': {
        'testtunnel': {
            'check': {
                'url': 'https://twitter.com/'
            },
            'proxy': {
                'host': '1.1.1.1'
            },
            'forwards': {
                'include': ['2.2.2.2'],
                'exclude': ['3.3.3.3']
            }
        }
    }
}



def test_basic_config():


    fd, path = tempfile.mkstemp()
    f = os.fdopen(fd,'w')
    f.write(yaml.dump(testcfg))
    f.flush()

    cfg = ny.get_config(path)
    ny.write_supervisor_conf()

    config = ConfigParser.ConfigParser()
    config.readfp(open(cfg['supervisor.conf']))

    # from IPython import embed
    # embed()
    print(config.get('program:testtunnel','command'))
    assert 'sshuttle -r 1.1.1.1 2.2.2.2 -x 3.3.3.3' in config.get('program:testtunnel','command')

def test_status():

    check_statuses = { check_result.name:check_result.status for check_result in ny.check_dependent_tunnels(None, True) }
    assert check_statuses

    # test_basic_config()
@@ -274,16 +274,91 @@
 1.1.1.1'
+,%0A                'sshuttle_args': '--no-latency-control madeuparg=someval'
 %0A       
@@ -857,66 +857,60 @@
 nfig
-.get('program:testtunnel','command'))%0A    assert 'sshuttle
+)%0A    assert '--no-latency-control madeuparg=someval
  -r 

add sshuttle options to config test