Skip to content

Commit cda1d2d

Browse files
committed
test for converting json into yaml added, renamed both test functions)
1 parent 432f4cf commit cda1d2d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/test_cli.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def test_convert(cli_args, tmpdir, monkeypatch):
409409

410410
@pytest.mark.parametrize("cli_args", [(['convert', '-y', '.']), (['convert',
411411
'--yes','.tmuxp.yaml'])])
412-
def test_convert_confirm(cli_args, tmpdir, monkeypatch):
412+
def test_convert_confirm_yaml(cli_args, tmpdir, monkeypatch):
413413

414414
tmpdir.join('.tmuxp.yaml').write(
415415
"""
@@ -428,6 +428,28 @@ def test_convert_confirm(cli_args, tmpdir, monkeypatch):
428428
{'session_name': 'hello'}, indent=2)
429429

430430

431+
@pytest.mark.parametrize("cli_args", [(['convert', '-y', '.']), (['convert',
432+
'--yes','.tmuxp.json'])])
433+
def test_convert_confirm_json(cli_args, tmpdir, monkeypatch):
434+
jsonData = {}
435+
jsonData['session_name'] = 'hello'
436+
with open(tmpdir.join('.tmuxp.json'), 'w') as jsonfile:
437+
json.dump(jsonData, jsonfile, indent=2)
438+
439+
440+
tmpdir.join('.oh-my-zsh').ensure(dir=True)
441+
monkeypatch.setenv('HOME', str(tmpdir))
442+
443+
with tmpdir.as_cwd():
444+
runner = CliRunner()
445+
446+
runner.invoke(cli.cli, cli_args, input='')
447+
assert tmpdir.join('.tmuxp.yaml').check()
448+
assert tmpdir.join('.tmuxp.yaml').open().read() == "session_name: hello\n"
449+
450+
451+
452+
431453

432454
@pytest.mark.parametrize("cli_args", [(['import'])])
433455
def test_import(cli_args, monkeypatch):

0 commit comments

Comments
 (0)