mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#17 Fix creating configuration files/dirs
This commit is contained in:
parent
ef7fe4685b
commit
9518416a2f
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
|
|
||||||
setup(name='thefuck',
|
setup(name='thefuck',
|
||||||
version=1.7,
|
version=1.8,
|
||||||
description="Magnificent app which corrects your previous console command",
|
description="Magnificent app which corrects your previous console command",
|
||||||
author='Vladimir Iakovlev',
|
author='Vladimir Iakovlev',
|
||||||
author_email='nvbn.rm@gmail.com',
|
author_email='nvbn.rm@gmail.com',
|
||||||
|
@ -4,21 +4,6 @@ from mock import patch, Mock
|
|||||||
from thefuck import main
|
from thefuck import main
|
||||||
|
|
||||||
|
|
||||||
def test_setup_user_dir():
|
|
||||||
with patch('thefuck.main.Path.is_dir', return_value=False), \
|
|
||||||
patch('thefuck.main.Path.mkdir') as mkdir, \
|
|
||||||
patch('thefuck.main.Path.touch') as touch:
|
|
||||||
main.setup_user_dir()
|
|
||||||
assert mkdir.call_count == 2
|
|
||||||
assert touch.call_count == 1
|
|
||||||
with patch('thefuck.main.Path.is_dir', return_value=True), \
|
|
||||||
patch('thefuck.main.Path.mkdir') as mkdir, \
|
|
||||||
patch('thefuck.main.Path.touch') as touch:
|
|
||||||
main.setup_user_dir()
|
|
||||||
assert mkdir.call_count == 0
|
|
||||||
assert touch.call_count == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_settings():
|
def test_get_settings():
|
||||||
with patch('thefuck.main.load_source', return_value=Mock(rules=['bash'])):
|
with patch('thefuck.main.load_source', return_value=Mock(rules=['bash'])):
|
||||||
assert main.get_settings(Path('/')).rules == ['bash']
|
assert main.get_settings(Path('/')).rules == ['bash']
|
||||||
|
@ -13,10 +13,10 @@ Rule = namedtuple('Rule', ('match', 'get_new_command'))
|
|||||||
def setup_user_dir():
|
def setup_user_dir():
|
||||||
"""Returns user config dir, create it when it doesn't exists."""
|
"""Returns user config dir, create it when it doesn't exists."""
|
||||||
user_dir = Path(expanduser('~/.thefuck'))
|
user_dir = Path(expanduser('~/.thefuck'))
|
||||||
if not user_dir.is_dir():
|
rules_dir = user_dir.joinpath('rules')
|
||||||
user_dir.mkdir()
|
if not rules_dir.is_dir():
|
||||||
user_dir.joinpath('rules').mkdir()
|
rules_dir.mkdir(parents=True)
|
||||||
user_dir.joinpath('settings.py').touch()
|
user_dir.joinpath('settings.py').touch()
|
||||||
return user_dir
|
return user_dir
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user