Skip to content

Commit

Permalink
80% coverage reached #48
Browse files Browse the repository at this point in the history
  • Loading branch information
perrette committed Apr 27, 2023
1 parent e91f13a commit b0ffc03
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion papers/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
38 changes: 37 additions & 1 deletion tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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)
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))

0 comments on commit b0ffc03

Please sign in to comment.