Skip to content

Commit 36298f2

Browse files
committed
tmuxp tmuxinator import tests, expect this may crash py3
1 parent fcdad68 commit 36298f2

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tmuxp/testsuite/test_config_tmuxinator.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@
1717
# https://github.com/aziz/tmuxinator
1818

1919

20+
def tmuxinator_to_tmuxp(sconf):
21+
'''
22+
23+
:param sconf: python dict for session configuration
24+
:type sconf: dict
25+
'''
26+
27+
tmuxp_config = {}
28+
29+
tmuxp_config['session_name'] = None
30+
31+
tmuxp_config['windows'] = []
32+
for w in sconf['windows']:
33+
for k, v in w.items():
34+
35+
windowdict = {}
36+
37+
windowdict['window_name'] = k
38+
if 'panes' in v:
39+
windowdict['panes'] = v['panes']
40+
if isinstance(v, basestring):
41+
windowdict['panes'] = [v]
42+
if 'layout' in v:
43+
windowdict['layout'] = v['layout']
44+
tmuxp_config['windows'].append(windowdict)
45+
46+
return tmuxp_config
47+
48+
2049
class TmuxinatorTest(unittest.TestCase):
2150

2251
tmuxinator_yaml = """\
@@ -50,12 +79,39 @@ class TmuxinatorTest(unittest.TestCase):
5079
]
5180
}
5281

82+
tmuxp_dict = {
83+
'session_name': None,
84+
'windows': [
85+
{
86+
'window_name': 'editor',
87+
'layout': 'main-vertical',
88+
'panes': [
89+
'vim',
90+
'guard'
91+
]
92+
},
93+
{
94+
'window_name': 'server',
95+
'panes': [
96+
'bundle exec rails s'
97+
]
98+
},
99+
{
100+
'window_name': 'logs',
101+
'panes': [
102+
'tail -f logs/development.log'
103+
]
104+
}
105+
]
106+
}
107+
53108
def test_config_to_dict(self):
54109
configparser = kaptan.Kaptan(handler='yaml')
55110
test_config = configparser.import_config(self.tmuxinator_yaml)
56111
yaml_to_dict = test_config.get()
57112
self.assertDictEqual(yaml_to_dict, self.tmuxinator_dict)
58113

114+
self.assertEqual(tmuxinator_to_tmuxp(yaml_to_dict), self.tmuxp_dict)
59115

60116
class TmuxinatorDeprecationsTest(unittest.TestCase):
61117

0 commit comments

Comments
 (0)