From b0ffc03a6f3c4c0f96b0dafeeac44386503d2289 Mon Sep 17 00:00:00 2001 From: perrette Date: Fri, 28 Apr 2023 01:32:38 +0200 Subject: [PATCH] 80% coverage reached #48 --- papers/__main__.py | 4 +++- tests/test_install.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/papers/__main__.py b/papers/__main__.py index 87a4c0e..0928935 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -402,7 +402,9 @@ def check_install(parser, o, config): install_doc = f"first execute `papers install --bibtex {config.bibtex or '...'} [ --local ]`" if not config.bibtex: - parser.error(f"--bibtex must be specified, or {install_doc}") + parser.print_help() + print(f"--bibtex must be specified, or {install_doc}") + raise PapersExit() elif not os.path.exists(config.bibtex): print(f'papers: error: no bibtex file found, do `touch {config.bibtex}` or {install_doc}') raise PapersExit() diff --git a/tests/test_install.py b/tests/test_install.py index 4bff273..10fbde8 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -325,6 +325,15 @@ def test_install_interactive4(self): self.assertFalse(config.git) self.assertFalse(config.gitlfs) + def test_install_interactive5(self): + self.papers(f"""install --local --filesdir files --bibtex bibbib.bib << EOF +y + +EOF""") + config = Config.load(self._path(".papers/config.json")) + self.assertTrue(config.git) + self.assertFalse(config.gitlfs) + class TestUndoGitLocal(TestBaseInstall): @@ -413,4 +422,31 @@ def test_undo(self): self.papers(f'redo --bibtex {self.mybib} --files {self.filesdir}') biblio = Biblio.load(self._path(self.mybib), '') - self.assertEqual(len(biblio.entries), 1) \ No newline at end of file + self.assertEqual(len(biblio.entries), 1) + + + +class TestUninstall(LocalInstallTest): + def test_uninstall(self): + self.assertTrue(self._exists(".papers/config.json")) + self.papers(f'uninstall') + self.assertFalse(self._exists(".papers/config.json")) + + +class TestUninstall2(GlobalInstallTest): + def test_uninstall(self): + self.assertTrue(self._exists(CONFIG_FILE)) + self.papers(f'install --force --local') + self.assertTrue(self._exists(".papers/config.json")) + self.assertTrue(self._exists(CONFIG_FILE)) + self.papers(f'uninstall') + self.assertFalse(self._exists(".papers/config.json")) + self.assertTrue(self._exists(CONFIG_FILE)) + + def test_uninstall(self): + self.papers(f'install --force --local') + self.assertTrue(self._exists(".papers/config.json")) + self.assertTrue(self._exists(CONFIG_FILE)) + self.papers(f'uninstall --recursive') + self.assertFalse(self._exists(".papers/config.json")) + self.assertFalse(self._exists(CONFIG_FILE)) \ No newline at end of file