Merge pull request #82 from pubs/bug/conf_cmd
Fixes bug in conf command and adds unittest
This commit is contained in:
commit
4f638ba9b6
@ -15,7 +15,7 @@ def command(conf, args):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
# get modif from user
|
# get modif from user
|
||||||
ui.edit_file(config.get_confpath())
|
ui.edit_file(config.get_confpath(), temporary=False)
|
||||||
|
|
||||||
new_conf = config.load_conf()
|
new_conf = config.load_conf()
|
||||||
try:
|
try:
|
||||||
|
@ -57,3 +57,68 @@ turing_meta = """\
|
|||||||
tags: [AI, computer]
|
tags: [AI, computer]
|
||||||
added: '2013-11-14 13:14:20'
|
added: '2013-11-14 13:14:20'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
sample_conf = """
|
||||||
|
[main]
|
||||||
|
|
||||||
|
# Where the pubs repository files (bibtex, metadata, notes) are located
|
||||||
|
pubsdir = /Users/fabien/research/renc/.pubs
|
||||||
|
|
||||||
|
# Where the documents files are located (default: $(pubsdir)/doc/)
|
||||||
|
docsdir = /Users/fabien/Dropbox/research/pubsdoc
|
||||||
|
|
||||||
|
# Specify if a document should be copied or moved in the docdir, or only
|
||||||
|
# linked when adding a publication.
|
||||||
|
doc_add = move
|
||||||
|
|
||||||
|
# the command to use when opening document files
|
||||||
|
open_cmd = open
|
||||||
|
|
||||||
|
# which editor to use when editing bibtex files.
|
||||||
|
# if using a graphical editor, use the --wait or --block option, i.e.:
|
||||||
|
# "atom --wait"
|
||||||
|
# "kate --block"
|
||||||
|
edit_cmd = "vim"
|
||||||
|
|
||||||
|
# If true debug mode is on which means exceptions are not catched and
|
||||||
|
# the full python stack is printed.
|
||||||
|
debug = False
|
||||||
|
|
||||||
|
[formating]
|
||||||
|
|
||||||
|
# Enable bold formatting, if the terminal supports it.
|
||||||
|
bold = False
|
||||||
|
|
||||||
|
# Enable italics, if the terminal supports it.
|
||||||
|
italics = False
|
||||||
|
|
||||||
|
# Enable colors, if the terminal supports it.
|
||||||
|
color = False
|
||||||
|
|
||||||
|
|
||||||
|
[theme]
|
||||||
|
|
||||||
|
# Here you can define the color theme used by pubs, if enabled in the
|
||||||
|
# 'formating' section. Predefined theme are available at:
|
||||||
|
# https://github.com/pubs/pubs/blob/master/extra/themes.md
|
||||||
|
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
# Comma-separated list of the plugins to load.
|
||||||
|
# The only current available plugin is alias.
|
||||||
|
active = alias,
|
||||||
|
|
||||||
|
[[alias]]
|
||||||
|
# new subcommands can be defined, e.g.:
|
||||||
|
# print = open --with lp
|
||||||
|
# evince = open --with evince
|
||||||
|
open = doc open
|
||||||
|
|
||||||
|
# shell commands can also be defined, by prefixing them with a bang `!`, e.g:
|
||||||
|
# count = !pubs list -k | wc -l
|
||||||
|
|
||||||
|
[internal]
|
||||||
|
# The version of this configuration file. Do not edit.
|
||||||
|
version = 0.6.0
|
||||||
|
"""
|
||||||
|
@ -35,17 +35,6 @@ class TestFileBroker(fake_env.TestFakeFs):
|
|||||||
meta_content = content.read_text_file('testrepo/meta/Page99.yaml')
|
meta_content = content.read_text_file('testrepo/meta/Page99.yaml')
|
||||||
self.assertEqual(fb.pull_metafile('Page99'), meta_content)
|
self.assertEqual(fb.pull_metafile('Page99'), meta_content)
|
||||||
|
|
||||||
def test_errors(self):
|
|
||||||
|
|
||||||
with self.assertRaises(IOError):
|
|
||||||
filebroker.FileBroker('testrepo', create = False)
|
|
||||||
|
|
||||||
fb = filebroker.FileBroker('testrepo', create = True)
|
|
||||||
with self.assertRaises(IOError):
|
|
||||||
fb.pull_bibfile('Page99')
|
|
||||||
with self.assertRaises(IOError):
|
|
||||||
fb.pull_metafile('Page99')
|
|
||||||
|
|
||||||
def test_errors(self):
|
def test_errors(self):
|
||||||
|
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
|
@ -531,6 +531,14 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
self.assertEqual(clean(correct[2]), clean(out[2]))
|
self.assertEqual(clean(correct[2]), clean(out[2]))
|
||||||
self.assertEqual(clean(correct[4]), clean(out[4]))
|
self.assertEqual(clean(correct[4]), clean(out[4]))
|
||||||
|
|
||||||
|
def test_conf(self):
|
||||||
|
cmds = ['pubs init',
|
||||||
|
('pubs conf', [str_fixtures.sample_conf]),
|
||||||
|
]
|
||||||
|
self.execute_cmds(cmds)
|
||||||
|
self.assertFileContentEqual(os.path.expanduser('~/.pubsrc'),
|
||||||
|
str_fixtures.sample_conf)
|
||||||
|
|
||||||
def test_editor_abort(self):
|
def test_editor_abort(self):
|
||||||
with self.assertRaises(FakeSystemExit):
|
with self.assertRaises(FakeSystemExit):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user