# Path: ifs/lib.py
# def get_download_filename(url, target):
# def download(url, target):
# def list_app_names():
# def list_apps():
# def search_app_strings(term):
# def export_source(source):
# def match_semver(string):
# def read_last_updated():
# def write_last_updated():
# def out_of_date(delay=86400):
#     def __init__(self, cmd):
#     def execute(self, autoprint=False):
#     def run(cls, cmd, autoprint=False):
#     def __init__(self, name, module=None):
#     def load(cls, app_name):
#     def load_external(cls, path):
#     def get_download_url(self, version=None):
#     def check_version(self):
#     def info(self):
#     def cmd_install_deps(self):
#     def cmd_install_app(self, version=None):
#     def install(self, version=None):
# class Cmd(object):
# class App(object):


from ifs import lib
    assert app is None


def test_get_download_url():
    url = lib.App.load('nginx').get_download_url()
    assert url == 'http://nginx.org/download/nginx-1.8.0.tar.gz'

    url = lib.App.load('nginx').get_download_url('1.6.3')
    assert url == 'http://nginx.org/download/nginx-1.6.3.tar.gz'


def test_app_info():
    info = lib.App.load('nginx').info()
    assert 'default_version' in info
    assert info['download_url'] == 'http://nginx.org/download/nginx-VERSION.tar.gz'


def test_check_version():
    app = lib.App('py.test')
    app.version_cmd = 'venv/bin/py.test --version'
    assert app.check_version() == '2.6.1'

    app.version_re = 'pytest version (\d+\.\d+\.\d+)'
    assert app.check_version() == '2.6.1'

    app.version_cmd = 'echo "pie"'
    assert app.check_version() == None


def test_cmd_install_deps():

# Path: ifs/lib.py
# def get_download_filename(url, target):
# def download(url, target):
# def list_app_names():
# def list_apps():
# def search_app_strings(term):
# def export_source(source):
# def match_semver(string):
# def read_last_updated():
# def write_last_updated():
# def out_of_date(delay=86400):
#     def __init__(self, cmd):
#     def execute(self, autoprint=False):
#     def run(cls, cmd, autoprint=False):
#     def __init__(self, name, module=None):
#     def load(cls, app_name):
#     def load_external(cls, path):
#     def get_download_url(self, version=None):
#     def check_version(self):
#     def info(self):
#     def cmd_install_deps(self):
#     def cmd_install_app(self, version=None):
#     def install(self, version=None):
# class Cmd(object):
# class App(object):


# Path: tests/test_lib.py
from ifs import lib

    assert app is None


def test_get_download_url():
    url = lib.App.load('nginx').get_download_url()
    assert url == 'http://nginx.org/download/nginx-1.8.0.tar.gz'

    url = lib.App.load('nginx').get_download_url('1.6.3')
    assert url == 'http://nginx.org/download/nginx-1.6.3.tar.gz'


def test_app_info():
    info = lib.App.load('nginx').info()
    assert 'default_version' in info
    assert info['download_url'] == 'http://nginx.org/download/nginx-VERSION.tar.gz'


def test_check_version():
    app = lib.App('py.test')
    app.version_cmd = 'venv/bin/py.test --version'
    assert app.check_version() == '2.6.1'

    app.version_re = 'pytest version (\d+\.\d+\.\d+)'
    assert app.check_version() == '2.6.1'

    app.version_cmd = 'echo "pie"'
    assert app.check_version() == None


def test_cmd_install_deps():

    app = lib.App('ls')