def setup_roles_files(): init_test_folder() put_file( "dev.cfg", put_folder("deploy", put_folder("project1", test_root())), ''' { "project_name":"name1", "dependencies":[ {"project_name": "project2"} ], "roles_seq":["main", "test"] } ''') put_file("index.js", put_folder("src", put_folder("project1", test_root())), '''//for test only''') put_file("dev.cfg", put_folder("deploy", put_folder("project2", test_root())), ''' { "project_name":"name2", "roles_seq":["main"] } ''')
def setup_init_config(): init_test_folder() (F(put_folder, "abc") >> \ F(put_folder, "deploy") >> \ F(put_folder, "roles") >> \ F(put_folder, "role1"))(test_root()) (F(put_folder, "abc") >> \ F(put_folder, "deploy") >> \ F(put_folder, "roles") >> \ F(put_folder, "role2"))(test_root())
def setup_muti_role_with_duplicated_key(): init_test_folder() put_file("main.yml", put_folder("defaults", put_folder("role1", put_folder("roles", test_root()))), ''' name1: y name2: x ''') put_file("main.yml", put_folder("defaults", put_folder("role2", put_folder("roles", test_root()))), ''' name1: y name3: x ''')
def setup_test_folder(): init_test_folder() def create(root_folder): put_file("level3_file", put_folder("level3", put_folder("level2", root_folder)), "hello level3_file") os.symlink( os.path.join(os.path.abspath(root_folder), "level2", "level3"), os.path.join(os.path.abspath(root_folder), "link_to_level2")) create(put_folder("level1", test_root()))
def setup_build(): init_test_folder() init_root(test_root()) project_folder = F(put_folder, "project1") >> F(put_folder, "deploy") put_file("main.yml", \ (project_folder >> F(put_folder, "roles") >> F(put_folder, "main") >> F(put_folder, "defaults"))(test_root()),\ '''--- name1: "a" name2: "b" ... ''') put_file("dev.cfg", \ project_folder(test_root()), '''{ "project_name": "project1", "roles_seq": ["main"] } ''')
def setup_deploy(): init_test_folder() project_folder = F(put_folder, "project1") >> F(put_folder, "deploy") put_file("main.host", \ (project_folder >> F(put_folder, ".dev"))(test_root()),\ '''[all:vars] name1=a b name2=b name3=c [remote] 1.1.1.1 ''') put_file("dev.cfg", \ project_folder(test_root()), '''{ "project_name": "project1", "roles_seq": ["main"], "predefined_variables": { "name1": "aa bb", "name2": "bb" } } ''')
def setup_get(): init_test_folder()
from config import cfg from assertpy import assert_that from codegenhelper import init_test_folder, remove_test_folder, test_root from nose import with_setup from helper import load_resource import os init_test_folder() def load_for_config(): load_resource('get_data_file') @with_setup(load_for_config, remove_test_folder) def test_config(): def dumy(config): assert_that(config.defaults).contains_entry({ 'db': 'service1' }).contains_entry({'db_port': '232'}) dumy(cfg(os.path.join(test_root(), 'get_data_file', 'db.cfg')))
def init_config_file(): init_test_folder() put_file('slogger.cfg', "./", '''[handlers] all_all ''')
def setup_clear_deploy(): init_test_folder() f = F(put_folder, ".dev") << F(put_folder, "deploy") << F( put_folder, "project1") f(test_root())
def setup_single_role(): init_test_folder() put_file("main.yml", put_folder("defaults", put_folder("main", put_folder("roles"))), ''' name1: x name2: y ''')