159 Commits

Author SHA1 Message Date
Bill Flynn
0c7ba85af9 Revisions subject to comments on PR #100
Additionally, reverted FakeSystemExit subclassing Exception, but added
an explicit __init__ so that we can emulate the SystemExit.code
functionality without having to change the superclass.
2017-12-08 17:49:19 -05:00
Bill Flynn
66c90c5d43 Added unittest to cover new behavior pubs
Unittest just checks that both `pubs` and `pubs --help` raise a
`SystemExit` exception with error code 0.  Due to how argparse
handles the `--help` keyword, this is the best way I could think to
provide test coverage without heavily modifying the parser structure
or the unittest infrastructure.

To ensure the `pubs` matches the behavior of `pubs --help`, it now
raises the same `SystemExit(0)` exception via `sys.exit(0)`.  And
in order to catch it in the unittest, I had to modify the
`FakeSystemExit` behavior slightly.
2017-11-30 14:48:50 -05:00
Bill Flynn
ac3a8d8bf2 Print help menu when no subcommands applied
Made subparsers not required in the main parser, but if no commands are parsed,
then the parser prints its help.  When a command is present, the normal
functionality preserved.

Removed the single unittest that checks for this exact behavior.
2017-11-28 17:32:13 -05:00
Olivier Mangin
6a26216c3e COSMIT 2017-10-19 15:46:42 -04:00
Olivier Mangin
a65873a7e0 Fixes abspath called on urls preventing to get content from url.
Fix #7
2017-10-19 15:40:58 -04:00
Olivier Mangin
47f5c918ea Fix #93: saves the modifications on edit -m. 2017-10-17 16:50:23 -04:00
Olivier Mangin
5c74f942c4 [Fix #88] Adds proper escaping for arguments in alias plugin. 2017-09-28 17:34:32 -04:00
Olivier Mangin
69d7587108 Adds test for configuration file content in usecase. 2017-08-01 23:43:06 -04:00
Fabien C. Y. Benureau
366575763c Remove duplicate test 2017-08-01 23:43:06 -04:00
Fabien C. Y. Benureau
0942df3b50 Fix pubs conf command 2017-08-01 23:43:06 -04:00
Olivier Mangin
da6f07c6c9 Adds basic API test for DOI and ISBN. 2017-07-22 15:42:12 -04:00
Olivier Mangin
4ffd62fe9f [notes] Allow different file extension for note file (see #70). 2017-07-12 10:41:51 -04:00
Olivier Mangin
9b6496d740 Removed commented code with old imports. 2017-07-11 17:26:08 -04:00
Olivier Mangin
323fb8b674 Fixes indent and removes unused io import. 2017-07-11 17:13:39 -04:00
Fabien C. Y. Benureau
3b4cfe635d Fix tests for Python 2
Also, some cleanup in fake_env.py
2017-07-11 17:08:53 -04:00
Fabien C. Y. Benureau
ce4b66e9b4 Fix unittests for Python 3 2017-07-11 17:08:52 -04:00
Olivier Mangin
a5466c940e Prepare configuration loading for autocomplete.
In particular, tries to load configuration when no argument is given.
Also removes unused check option from load_conf.
2017-07-08 00:10:15 -04:00
Olivier Mangin
6c2f0f6f8d Moves editor commands to ui to avoid using with wrong editor values.
For now, the editor_input and edit_file functions do not make sense
outside of the context of an ui. Having them in the content module
was confusing. (See issue fixed by a600855.)
2017-05-24 13:51:02 -04:00
Olivier Mangin
8ae339d870 Removes debug code and unused code. 2017-04-14 19:10:08 -04:00
Fabien C. Y. Benureau
0f84268ebf Honor custom pubsdoc in config 2016-06-06 00:25:27 +02:00
Fabien C. Y. Benureau
2aad93b526 Simplify, update the testsuite
Replace the in-house stubbing by the facilities offered
by pyfakefs for running tests. We don't use `io.open`
anymore, because pyfakefs does not stub it correctly.
We rely on a patched version of pyfakefs, as a few bug
remain in the official repo.
2016-06-05 21:48:19 +02:00
Olivier Mangin
2859e4bc62 More refactoring to remove code duplication. Also adds tests. 2016-02-02 21:21:24 -05:00
Fabien Benureau
e5b898c5c2 Cache implemented
The implementation is designed to be robust to filesystems having integers
or nanosecond stat time.

Added a requirements.txt file for the tests:
`pip install -r tests/requirements.txt` to install the necessary packages
to run the tests.

Fix #13, Fix #14
2016-01-23 02:03:02 +01:00
Fabien Benureau
9ad6d8db25 Simplified fake_env code
1. Removed the unicode wrapper around fake_env io
2. Overrided pyfakefs cStringIO with StringIO (Python 2.x)
3. copy_dir will copy file in binary file to the fake filesystem
   *unless* they are bib, yaml, txt or md files
4. ui.handle_exception() conserve traceback

Numerous unicode subtelties required diving into pyfakefs and configobj
source code. Unicode on Python 2.x is the worst.
2016-01-21 16:18:16 +01:00
Fabien Benureau
620eef4ace Fix expectedFailure tests 2016-01-17 02:42:56 +01:00
Fabien Benureau
e979aae85b Better rename and error dialogue
info() messages now print on stdout. warning() and error() still
print on stderr.

Fix #50
2016-01-16 21:52:36 +01:00
Olivier Mangin
2d9fa9af94 Comments out failing test from #25. 2016-01-15 19:02:56 -05:00
Olivier Mangin
2720d13049 Moves test of config file creation to its own test. 2016-01-15 19:02:56 -05:00
Olivier Mangin
ecb1910084 Better error message on UnicodeDecodeError for reading text file.
Also renames read_file to read_text_file which is what is implemented.
Fixes #51.
2016-01-15 19:02:56 -05:00
Olivier Mangin
b12c6297f0 Adds exception catching in main command. 2016-01-15 19:02:56 -05:00
Olivier Mangin
7f6dde2f0c Temporary fix ExpectedFailure does not handle SystemExit on python 2.
Actually the test not only is expected to fail but it misses a file
which causes an error instead of a failure on python 2. Should be
addressed by #25.
2016-01-15 19:02:56 -05:00
Olivier Mangin
e3df872e65 Updates for new version of pyfakefs.
Modules should now be imported from the pyfakefs package.
2016-01-15 19:02:43 -05:00
Olivier Mangin
9d0a800d8b Cleans up old imports of ConfigParser. 2016-01-15 16:45:06 -05:00
Fabien Benureau
b2ebc67f5e Handle Unicode BOM in bibfile
In particular, xml2bib file created without the `-nb` options would trip bibtexparser.

Fixes #23
2015-12-20 22:20:01 +01:00
Fabien Benureau
220e5ad9a8 Fix tests for python 3 2015-12-20 19:26:33 +01:00
Fabien Benureau
3b0ba0bb3c Test for leading space in citekeys
This test is expected to fail. Nose does not handle that yet (treats it as false).
As such, changes have been made to make tests discoverable by unittest.
You may want to uninstall nose and do something like:
alias nosetests="python -m unittest discover"
in your bashrc

Related: #25
2015-12-20 18:51:43 +01:00
Fabien Benureau
0ab8310089 Fix color in test_oneliner 2015-12-20 18:51:00 +01:00
Fabien Benureau
f843aebcbd Better handle utf-8 citekeys
Utf-8 citekeys generate errors in bibtexparser. Until this is fixed,
this commit replace the stack-trace by a clear error message.

related: #28
2015-12-16 16:38:40 +01:00
73
a926c4c654 adds a *doc add|remove|export|open* command; depricates commands *open* and *attach*; fixed typos in readme.md and uis; 2015-12-13 21:34:48 +01:00
Olivier Mangin
af207e2604 Adds alias plugin test and fix its config access. 2015-12-11 20:11:38 -05:00
Fabien Benureau
4b21fa1355 Fix handling of version in argument parser 2015-12-10 21:50:18 +01:00
73
2871588703 implements #19 2015-12-10 12:50:38 +01:00
Fabien Benureau
392ee0c3c1 Merge branch 'master' into feat/new_config
Add StringIO and BytesIO to FakeIO.
Fixes bytes/string problem in update()
2015-12-07 11:49:16 +01:00
Fabien Benureau
3099d353f9 Configurable colors and update improvement
Add a theme section in the configuration file to allow users to
set the colors used by different elements of the ui.

Improve the update mechanism so that incremental changes to the
configuration file can be incorporated.
2015-12-07 11:04:34 +01:00
Fabien Benureau
757a8b300e Add an update mechanism for old repositories
The update is done transparently, and displays a warning message explaining the change.
All the update machinery has been moved to the new update module.
2015-12-05 20:36:19 +01:00
Olivier Mangin
681ae65c9e Fixes issue #35.
pubs tag non-existing-citekey some-tag

Know fails as expected. The commit however removes the option of listing
tags as separate arguments.
2015-12-04 23:44:05 -05:00
Olivier Mangin
5480f79d8d Fixes ˇpubs tag citekey :sometagˇ not working.
Also adds a few tests for the tag command.
2015-12-04 23:20:19 -05:00
Fabien Benureau
93c54939b3 Rewritten config module
It depends on configobj, is cleaner and simpler than the previous implementation.
It adds comments in the config file, and type verification.

Related: #18
2015-12-04 20:49:05 +01:00
Fabien Benureau
4b3b2a23bd Improves interface of PrintUI
`print_out()` is replaced by `message()`, that redirect the output to
the stdout controlled by the PrintUI instance. Other than that, can be
used the same way as `print()`.
2015-12-03 16:09:54 +01:00
Fabien Benureau
b71494ed42 Fix pubs init TypeError
The error was due to python 2 and 3 not playing nice when opening files.
This is probably linked to some botched unicode handling on our part somewhere
else is the package, and needs to be addressed when the `configs` module is
rewritten.

Also addresses some other minor unicode bugs.

Fix #27.
Related #18.
2015-12-03 10:00:19 +01:00