From 47f5c918ea9824948ad50d45b73762c5dfe2eeeb Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 17 Oct 2017 16:50:23 -0400 Subject: [PATCH] Fix #93: saves the modifications on `edit -m`. --- pubs/commands/edit_cmd.py | 3 ++- tests/test_usecase.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pubs/commands/edit_cmd.py b/pubs/commands/edit_cmd.py index 0af4e5e..c5e42d2 100644 --- a/pubs/commands/edit_cmd.py +++ b/pubs/commands/edit_cmd.py @@ -51,6 +51,7 @@ def command(conf, args): if meta: new_paper = Paper(paper.citekey, paper.bibdata, metadata=content) + rp.push_paper(new_paper, overwrite=True, event=False) else: new_paper = Paper.from_bibentry(content, metadata=paper.metadata) @@ -62,7 +63,7 @@ def command(conf, args): choice = options[ui.input_choice( options, ['o', 'e', 'a'], question='A paper already exists with this citekey.' - )] + )] if choice == 'abort': break diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 53d7141..f6e15de 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -579,6 +579,20 @@ class TestUsecase(DataCommandTestCase): ] self.execute_cmds(cmds) + def test_edit_meta(self): + meta = str_fixtures.turing_meta + + line = '[Page99] Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web." (1999) \n' + line1 = re.sub('\n', '| AI,computer\n', line) + + cmds = ['pubs init', + 'pubs add data/pagerank.bib', + ('pubs list', [], line), + ('pubs edit -m Page99', [meta]), + ('pubs list', [], line1), + ] + self.execute_cmds(cmds) + def test_export(self): cmds = ['pubs init', ('pubs add', [str_fixtures.bibtex_external0]),