From 0942df3b50deeab2c26776d90fe87395094bb0c6 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Sat, 22 Jul 2017 17:27:44 +0200 Subject: [PATCH] Fix pubs conf command --- pubs/commands/conf_cmd.py | 2 +- tests/str_fixtures.py | 65 +++++++++++++++++++++++++++++++++++++++ tests/test_usecase.py | 7 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/pubs/commands/conf_cmd.py b/pubs/commands/conf_cmd.py index eceaf8d..88d0c78 100644 --- a/pubs/commands/conf_cmd.py +++ b/pubs/commands/conf_cmd.py @@ -15,7 +15,7 @@ def command(conf, args): while True: # get modif from user - ui.edit_file(config.get_confpath()) + ui.edit_file(config.get_confpath(), temporary=False) new_conf = config.load_conf() try: diff --git a/tests/str_fixtures.py b/tests/str_fixtures.py index ae80fcc..5b9f6f7 100644 --- a/tests/str_fixtures.py +++ b/tests/str_fixtures.py @@ -57,3 +57,68 @@ turing_meta = """\ tags: [AI, computer] 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 +""" diff --git a/tests/test_usecase.py b/tests/test_usecase.py index fd191f6..b8a1dc0 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -531,6 +531,13 @@ class TestUsecase(DataCommandTestCase): self.assertEqual(clean(correct[2]), clean(out[2])) 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) + + def test_editor_abort(self): with self.assertRaises(FakeSystemExit): cmds = ['pubs init',