Skip to content

Commit

Permalink
Update changes. Update config.inline and add tests. Updates to test_c…
Browse files Browse the repository at this point in the history
…onfig to remove start_directory from panes
  • Loading branch information
tony committed Nov 9, 2013
1 parent dcf6b88 commit 6108748
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 38 deletions.
21 changes: 21 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ Here you can find the recent changes to tmuxp.
0.1-dev
-------

2013-11-08
''''''''''

- [cli] [freeze] - ``$ tmuxp freeze`` will now freeze a window with a
``start_directory`` when all panes in a window are inside the same
directory.
- [cli] [config] [tests] :meth:`config.inline` will now turn panes with no
other attributes and 1 command into a single item value.

.. code-block:: yaml
- panes:
- shell_command: top
# will now inline to:
- panes
- top
This will improve ``$ tmuxp freeze``
2013-11-07
''''''''''

Expand Down
3 changes: 3 additions & 0 deletions tmuxp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def inline(sconf):

if ('shell_command' in sconf and isinstance(sconf['shell_command'], list) and len(sconf['shell_command']) == 1):
sconf['shell_command'] = sconf['shell_command'][0]

if len(sconf.keys()) == int(1):
sconf = sconf['shell_command']
if ('shell_command_before' in sconf and isinstance(sconf['shell_command_before'], list) and len(sconf['shell_command_before']) == 1):
sconf['shell_command_before'] = sconf['shell_command_before'][0]

Expand Down
75 changes: 37 additions & 38 deletions tmuxp/testsuite/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
logger = logging.getLogger(__name__)
TMUXP_DIR = os.path.join(os.path.dirname(__file__), '.tmuxp')
current_dir = os.path.abspath(os.path.dirname(__file__))
example_dir = os.path.abspath(os.path.join(current_dir, '..', '..', 'examples'))
example_dir = os.path.abspath(os.path.join(
current_dir, '..', '..', 'examples'))


sampleconfigdict = {
Expand Down Expand Up @@ -139,12 +140,17 @@ class ExpandTest(TestCase):
'session_name': 'sampleconfig',
'start_directory': '~',
'windows': [{
'shell_command': 'top',
'window_name': 'editor',
'panes': [
{
'shell_command': [
'vim',
'top'
]
},
{
'shell_command': ['vim'],
},
},
{
'shell_command': 'cowsay "hey"'
},
Expand Down Expand Up @@ -200,12 +206,15 @@ class ExpandTest(TestCase):
'start_directory': '~',
'windows': [
{
'shell_command': ['top'],
'window_name': 'editor',
'panes': [
{
'shell_command': ['vim', 'top'],
},
{
'shell_command': ['vim'],
}, {
},
{
'shell_command': ['cowsay "hey"']
},
],
Expand Down Expand Up @@ -274,7 +283,7 @@ class InlineTest(TestCase):
'window_name': 'editor',
'panes': [
{
'start_directory': '~', 'shell_command': ['vim'],
'shell_command': ['vim'],
}, {
'shell_command': ['cowsay "hey"']
},
Expand All @@ -284,8 +293,9 @@ class InlineTest(TestCase):
{
'window_name': 'logging',
'panes': [
{'shell_command': ['tail -F /var/log/syslog'],
'start_directory':'/var/log'}
{
'shell_command': ['tail -F /var/log/syslog'],
}
]
},
{
Expand All @@ -305,35 +315,26 @@ class InlineTest(TestCase):
'shell_command': 'top',
'window_name': 'editor',
'panes': [
{
'start_directory': '~',
'shell_command': 'vim',
},
{
'shell_command': 'cowsay "hey"'
},
'vim',
'cowsay "hey"'
],
'layout': 'main-verticle'
},
{
'window_name': 'logging',
'panes': [
{
'shell_command': 'tail -F /var/log/syslog',
'start_directory': '/var/log'
}
'tail -F /var/log/syslog',
]
},
{
'options': {
'automatic_rename': True,
},
'panes': [
{
'shell_command': 'htop'
}
'htop'
]
}
},

]
}

Expand All @@ -358,7 +359,6 @@ class InheritanceTest(TestCase):
'start_directory': '~',
'panes': [
{
'start_directory': '~',
'shell_command': ['vim'],
},
{
Expand All @@ -372,7 +372,6 @@ class InheritanceTest(TestCase):
'panes': [
{
'shell_command': ['tail -F /var/log/syslog'],
'start_directory':'/var/log'
}
]
},
Expand All @@ -381,7 +380,6 @@ class InheritanceTest(TestCase):
'panes': [
{
'shell_command': ['htop'],
'start_directory': '/etc/'
}
]
},
Expand All @@ -407,9 +405,9 @@ class InheritanceTest(TestCase):
'start_directory': '~',
'panes': [
{
'start_directory': '~', 'shell_command': ['vim'],
'shell_command': ['vim'],
}, {
'shell_command': ['cowsay "hey"'], 'start_directory': '~',
'shell_command': ['cowsay "hey"'],
},
],
'layout': 'main-verticle'
Expand All @@ -419,23 +417,22 @@ class InheritanceTest(TestCase):
'panes': [
{
'shell_command': ['tail -F /var/log/syslog'],
'start_directory':'/var/log'
}
]
},
{
'window_name': 'shufu',
'panes': [
{
'shell_command': ['htop'], 'start_directory': '/etc/'
'shell_command': ['htop'],
}
]
},
{
'options': {'automatic_rename': True, },
'panes': [
{
'shell_command': ['htop'], 'start_directory':'/'
'shell_command': ['htop'],
}
]
}
Expand All @@ -458,12 +455,13 @@ def test_start_directory(self):
window_start_directory = session_start_directory

for paneconfitem in windowconfitem['panes']:
if 'start_directory' in paneconfitem:
pane_start_directory = paneconfitem['start_directory']
elif window_start_directory:
paneconfitem['start_directory'] = window_start_directory
elif session_start_directory:
paneconfitem['start_directory'] = session_start_directory
# if 'start_directory' in paneconfitem:
# pane_start_directory = paneconfitem['start_directory']
# elif window_start_directory:
# paneconfitem['start_directory'] = window_start_directory
# elif session_start_directory:
# paneconfitem['start_directory'] = session_start_directory
pass

self.maxDiff = None
self.assertDictEqual(config, self.config_after)
Expand Down Expand Up @@ -813,7 +811,8 @@ def test_expands_blank(self):

self.maxDiff = None

test_config = kaptan.Kaptan().import_config(self.yaml_config_file).get()
test_config = kaptan.Kaptan().import_config(
self.yaml_config_file).get()

self.assertDictEqual(
config.expand(test_config),
Expand Down

0 comments on commit 6108748

Please sign in to comment.