def test_get_categories(): 'test to get categories form scripts list' set = ScriptSet.from_scriptslist( ScriptsList(get_datadir()+'/scripts.list')) # checks all items are Category class. for category in set.categories(): assert 'Category' == category.__class__.__name__, category.__class__ # checks get Category Instance by spefied category name. ast_cats = ['Networking', 'Graphic', 'Localization', 'Productivity', 'Entertain', 'Customize','Game', 'Multimedia'] for ast_category in ast_cats: cat = set.categories(ast_category) cat.lang = 'enUS' assert ast_category == cat.name, cat.name
from lazyscript.script import SourceList from t import get_repodir, get_datadir source_list = SourceList(get_datadir()+'/source.list') repo_path = get_repodir() def test_save_list(): "test to save source list." list = [] list.append({'name':'firstscript', 'tag':'vim', 'category':'editor', 'repo':repo_path, 'ver':''}) source_list.save(list) def test_load_list(): "test to load source list." source_list.update() assert source_list.items()[0]['name'] == 'firstscript',\ "can not load source."
def test_from_repo(): "test to create a source list from a git repositry." list = ScriptList.from_repo(get_datadir()+'scriptspoll/7796c33a9348485b055f671c686568b0/') assert len(list.items()) == 31 list.path = get_datadir()+'/scripts.list' list.save()
from lazyscript.script import ScriptList from t import get_repodir, get_datadir source_list = ScriptList(get_datadir()+'/source.list') repo_path = get_repodir() def test_save_list(): "test to save source list." list = [] list.append({'name':'firstscript', 'tag':'vim', 'category':'editor', 'repo':repo_path, 'ver':''}) source_list.save(list) def test_load_list(): "test to load source list." source_list.update() assert source_list.items()[0]['name'] == 'firstscript',\ "can not load source." def test_from_repo(): "test to create a source list from a git repositry." list = ScriptList.from_repo(get_datadir()+'scriptspoll/7796c33a9348485b055f671c686568b0/') assert len(list.items()) == 31 list.path = get_datadir()+'/scripts.list' list.save()
def test_get_categories(): "test to get categories form source list" set = ScriptSet.from_sourcelist(SourceList(get_datadir() + "/source.list")) assert set.categories("editor")[0].name == "hellovim", set.categories
def test_from_repo(): "test to create a source list from a git repositry." list = ScriptsList.from_repo(remote_repo, get_repodir()) list.path = get_datadir()+'/scripts.list' list.save()
from lazyscripts.script import ScriptsList from t import get_repodir, get_datadir, remote_repo scripts_list = ScriptsList(get_datadir()+'/scripts.list') repo_path = get_repodir() def test_save_list(): "test to save scripts list." list = [] list.append({'name':'firstscript', 'tag':'vim', 'category':'editor', 'repo':repo_path, 'ver':''}) scripts_list.save(list) def test_load_list(): "test to load scripts list." scripts_list.update() assert scripts_list.items()[0]['name'] == 'firstscript',\ "can not load source." def test_from_repo(): "test to create a source list from a git repositry." list = ScriptsList.from_repo(remote_repo, get_repodir()) list.path = get_datadir()+'/scripts.list' list.save()
from lazyscripts.category import Category from lazyscripts.script import ScriptSet, ScriptsList, ScriptsBuilder from lazyscripts.repo import git, sign_repopath from t import get_repodir, get_datadir, remote_repo set = ScriptSet.from_scriptslist( ScriptsList(get_datadir()+'/scripts.list'), True) _repos = {remote_repo:git.Repo(get_repodir()+'/'+sign_repopath(remote_repo))} _cat = Category(name='Networking', scripts_builder=ScriptsBuilder(_repos)) e = {'repo': remote_repo, 'category': 'Networking', 'name': 'ie6', 'id': 'ie6', 'selected':False} _cat.add_entry(e) def test_get_script_from_category(): "test to get script form a category." assert 'Script' == _cat.get('ie6').__class__.__name__ def test_get_categories(): 'test to get categories form scripts list' # checks all items are Category class. for category in set.categories(): assert 'Category' == category.__class__.__name__, category.__class__ # checks get Category Instance by spefied category name. ast_cats = ['Networking', 'Graphic', 'Localization', 'Productivity', 'Entertain', 'Customize','Game', 'Multimedia']
def test_get_subscript(): e = {'repo': get_datadir()+'/scriptspoll/7796c33a9348485b055f671c686568b0/', 'category': 'Networking', 'name': 'ie6', 'id': 'ie6'} _cat.add_entry(e) subscripts = _cat.get('ie6').get_subscripts() assert subscripts[0].name == 'ie6_seluser.py', subscripts[0].name
from lazyscripts.category import Category from lazyscripts.script import ScriptSet, ScriptsList, ScriptsBuilder from lazyscripts.repo import git from t import get_repodir, get_datadir set = ScriptSet.from_scriptslist( ScriptsList(get_datadir()+'/scripts.list')) _repos = {get_datadir()+'/scriptspoll/7796c33a9348485b055f671c686568b0/': git.Repo(get_datadir()+'/scriptspoll/7796c33a9348485b055f671c686568b0/')} _cat = Category(name='Networking', scripts_builder=ScriptsBuilder(_repos)) def test_get_script_from_category(): "test to get script form a category." e = {'repo': get_datadir()+'/scriptspoll/7796c33a9348485b055f671c686568b0/', 'category': 'Networking', 'name': 'ie6_after.sh', 'id': 'ie6_after.sh'} _cat.add_entry(e) assert 'Script' == _cat.get('ie6_after.sh').__class__.__name__ def test_get_categories(): 'test to get categories form scripts list' set = ScriptSet.from_scriptslist( ScriptsList(get_datadir()+'/scripts.list')) # checks all items are Category class. for category in set.categories(): assert 'Category' == category.__class__.__name__, category.__class__ # checks get Category Instance by spefied category name. ast_cats = ['Networking', 'Graphic', 'Localization', 'Productivity', 'Entertain', 'Customize','Game', 'Multimedia']
def test_get_script_from_category(): "test to get script form a category." e = {'repo': get_datadir()+'/scriptspoll/7796c33a9348485b055f671c686568b0/', 'category': 'Networking', 'name': 'ie6_after.sh', 'id': 'ie6_after.sh'} _cat.add_entry(e) assert 'Script' == _cat.get('ie6_after.sh').__class__.__name__
def test_get_categories(): "test to get categories form source list" set = ScriptSet.from_sourcelist(ScriptList(get_datadir() + "/scripts.list")) assert set.categories("Network")[0].name == "hellovim", set.categories
def test_create_scriptrepo(): "test to create an ensure the local repositery is unique." try: signed_repopath = sign_repopath(get_repodir(), get_datadir()+'unexist/') except NoScriptPoll, e: assert 1 != 2, 'can not avoid the script poll not exists.'
# -*- encoding=utf8 -*- from lazyscript.repo import git, create_scriptrepo, sign_repopath, NoScriptPoll from t import get_repodir,get_datadir repo = git.Repo(get_repodir()) def test_create_scriptrepo(): "test to create an ensure the local repositery is unique." try: signed_repopath = sign_repopath(get_repodir(), get_datadir()+'unexist/') except NoScriptPoll, e: assert 1 != 2, 'can not avoid the script poll not exists.' signed_repopath = sign_repopath(get_repodir(), get_datadir()+'scriptpoll/') want_path = signed_repopath+'/.git' repo = create_scriptrepo(get_repodir(), get_datadir()+'scriptpoll/') assert repo.path == signed_repopath+'/.git', repo.path # clean import os os.system('rm -rf '+signed_repopath) def test_get_blob(): "test to get blob with spefied commit id." repo = git.Repo(get_repodir()) blob = repo.get_blob('test_get.sh') assert blob.name == 'test_get.sh' blob = repo.get_blob('test_2.sh') assert blob.name == 'test_2.sh'
def _test_from_repo(): "test to create a source list from a git repositry." list = ScriptsList.from_repo(get_datadir()+'scriptspoll/7796c33a9348485b055f671c686568b0/') list.path = get_datadir()+'/scripts.list' list.save()
from lazyscripts.script import ScriptsList from t import get_repodir, get_datadir scripts_list = ScriptsList(get_datadir()+'/source.list') repo_path = get_repodir() def test_save_list(): "test to save scripts list." list = [] list.append({'name':'firstscript', 'tag':'vim', 'category':'editor', 'repo':repo_path, 'ver':''}) scripts_list.save(list) def test_load_list(): "test to load scripts list." scripts_list.update() assert scripts_list.items()[0]['name'] == 'firstscript',\ "can not load source." # @FIXME the scripts poll name is changed. def _test_from_repo(): "test to create a source list from a git repositry." list = ScriptsList.from_repo(get_datadir()+'scriptspoll/7796c33a9348485b055f671c686568b0/') list.path = get_datadir()+'/scripts.list' list.save()