Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_in_session_scope():
sconfig = load_yaml(fixtures.shell_command_before_session.before)
config.validate_schema(sconfig)
assert config.expand(sconfig) == sconfig
assert config.expand(config.trickle(sconfig)) == load_yaml(
fixtures.shell_command_before_session.expected
)
def test_before_load_true_if_test_passes_with_args(server):
config_script_completes = loadfixture(
"workspacebuilder/config_script_completes.yaml"
)
assert os.path.exists(os.path.join(fixtures_dir, 'script_complete.sh'))
sconfig = kaptan.Kaptan(handler='yaml')
yaml = config_script_completes.format(
fixtures_dir=fixtures_dir,
script_complete=os.path.join(fixtures_dir, 'script_complete.sh') + ' -v',
)
sconfig = sconfig.import_config(yaml).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
with temp_session(server) as session:
builder.build(session=session)
def test_before_load_true_if_test_passes(server):
config_script_completes = loadfixture(
"workspacebuilder/config_script_completes.yaml"
)
assert os.path.exists(os.path.join(fixtures_dir, 'script_complete.sh'))
sconfig = kaptan.Kaptan(handler='yaml')
yaml = config_script_completes.format(
fixtures_dir=fixtures_dir,
script_complete=os.path.join(fixtures_dir, 'script_complete.sh'),
)
sconfig = sconfig.import_config(yaml).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
with temp_session(server) as session:
builder.build(session=session)
HOME=os.path.realpath(os.path.expanduser('~'))
)
# test order of `panes` (and pane_index) above aganist pane_dirs
pane_paths = [
'/usr/bin',
'/usr',
'/usr/sbin',
os.path.realpath(os.path.expanduser('~')),
]
s = session
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
window_count = len(session._windows) # current window count
assert len(s._windows) == window_count
for w, wconf in builder.iter_create_windows(s):
for p in builder.iter_create_panes(w, wconf):
w.select_layout('tiled') # fix glitch with pane size
p = p
assert len(s._windows) == window_count
assert isinstance(w, Window)
assert len(s._windows) == window_count
window_count += 1
def test_before_load_throw_error_if_file_not_exists(server):
config_script_not_exists = loadfixture(
"workspacebuilder/config_script_not_exists.yaml"
)
sconfig = kaptan.Kaptan(handler='yaml')
yaml = config_script_not_exists.format(
fixtures_dir=fixtures_dir,
script_not_exists=os.path.join(fixtures_dir, 'script_not_exists.sh'),
)
sconfig = sconfig.import_config(yaml).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
with temp_session(server) as sess:
session_name = sess.name
temp_session_exists = server.has_session(sess.name)
assert temp_session_exists
with pytest.raises((exc.BeforeLoadScriptNotExists, OSError)) as excinfo:
builder.build(session=sess)
excinfo.match(r'No such file or directory')
result = server.has_session(session_name)
assert not result, "Kills session if before_script doesn't exist"
def test_before_load_throw_error_if_retcode_error(server):
config_script_fails = loadfixture("workspacebuilder/config_script_fails.yaml")
sconfig = kaptan.Kaptan(handler='yaml')
yaml = config_script_fails.format(
fixtures_dir=fixtures_dir,
script_failed=os.path.join(fixtures_dir, 'script_failed.sh'),
)
sconfig = sconfig.import_config(yaml).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
with temp_session(server) as sess:
session_name = sess.name
with pytest.raises(exc.BeforeLoadScriptError):
builder.build(session=sess)
result = server.has_session(session_name)
assert not result, "Kills session if before_script exits with errcode"
def test_shell_command_before():
"""Config inheritance for the nested 'start_command'."""
test_config = fixtures.shell_command_before.config_unexpanded
test_config = config.expand(test_config)
assert test_config == fixtures.shell_command_before.config_expanded
test_config = config.trickle(test_config)
assert test_config == fixtures.shell_command_before.config_after