From 7518dfd56aee97784dca3aac5310ff783393e0c8 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 26 Jul 2018 16:25:30 +0200 Subject: [PATCH 1/6] [Fix #85] Adds changelog file. --- changelog.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..0b0f0af --- /dev/null +++ b/changelog.md @@ -0,0 +1,68 @@ +# Changelog + + +## Current master + +[Full Changelog](https://github.com/pubs/pubs/compare/v0.7.0...master) + + +### Implemented enhancements + +- Better dialog after editing paper [(#142)](https://github.com/pubs/pubs/issues/142) + +- Add a command to open urls [(#139)](https://github.com/pubs/pubs/issues/139) + +- More robust cache on version change [(#138)](https://github.com/pubs/pubs/issues/138) + +- Allow utf8 citekeys [(#133)](https://github.com/pubs/pubs/issues/133) + +- Adds tag list completion in `pubs add -t ` [(#130)](https://github.com/pubs/pubs/issues/130) + +- Wider Travis coverage ([#107](https://github.com/pubs/pubs/issues/107) and [#108](https://github.com/pubs/pubs/issues/108)) + +- Uses bibtexparser bwriter instead of internal encoder and adds `--ignore-fields` option to export. [(#106)](https://github.com/pubs/pubs/issues/106) + +- Configurable alias descriptions [(#104)](https://github.com/pubs/pubs/issues/104) + +- Support year ranges in query [(#102)](https://github.com/pubs/pubs/issues/102) + + +### Fixed bugs + +- [[#95]](https://github.com/pubs/pubs/issues/95) Error message when editor is missing [(#141)](https://github.com/pubs/pubs/issues/141) + +- Fixes tests for printing help on `--help` and without argument. [(#137)](https://github.com/pubs/pubs/issues/137) + +- [[#126]](https://github.com/pubs/pubs/issues/126) Removes journal customization [(#127)](https://github.com/pubs/pubs/issues/127) + +- Fixes Travis failure on installing python3 for OSX [(#125)](https://github.com/pubs/pubs/issues/125) + +- [[#119]](https://github.com/pubs/pubs/issues/119) Removes link and DOI customization. [(#124)](https://github.com/pubs/pubs/issues/124) + +- [[#122]](https://github.com/pubs/pubs/issues/122) Fixes common strings [(#123)](https://github.com/pubs/pubs/issues/123) + +- [[#28]](https://github.com/pubs/pubs/issues/28) allow utf8 in citekeys [(#120)](https://github.com/pubs/pubs/issues/120) + +- Fixes field orders to use 'url' and fixes broken test. [(#118)](https://github.com/pubs/pubs/issues/118) + +- [[#25]](https://github.com/pubs/pubs/issues/25) Fix bibtex testcase [(#117)](https://github.com/pubs/pubs/issues/117) + +- [[#103]](https://github.com/pubs/pubs/issues/103) Fixes unicode comparison [(#116)](https://github.com/pubs/pubs/issues/116) + +- [[#95]](https://github.com/pubs/pubs/issues/95) robust handling of DOIs [(#105)](https://github.com/pubs/pubs/issues/105) + +- [[#99]](https://github.com/pubs/pubs/issues/99) Print help when no subcommand is provided [(#100)](https://github.com/pubs/pubs/issues/100) + +- Fix defaults not used in config. [(#97)](https://github.com/pubs/pubs/issues/97) + +- Fixes content not read from urls because of call to `os.abspath` [(#96)](https://github.com/pubs/pubs/issues/96) + +- [[#93]](https://github.com/pubs/pubs/issues/93) actually save the modifications on `edit -m`. [(#94)](https://github.com/pubs/pubs/issues/94) + +- [[#88]](https://github.com/pubs/pubs/issues/88) Adds proper escaping for +arguments in alias plugin. [(#91)](https://github.com/pubs/pubs/issues/91) + + +## [v0.7.0](https://github.com/pubs/pubs/compare/v0.6.0...v0.7.0) (2017-08-06) + +[Full Changelog](https://github.com/pubs/pubs/compare/v0.6.0...v0.7.0) From 754e9268938d25a0312e12d3e5e6706bcd26e08d Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Mon, 30 Jul 2018 17:27:12 +0200 Subject: [PATCH 2/6] Adds authors of PRs to changelog and missing ksunden to readme. --- changelog.md | 8 ++++---- readme.md | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 0b0f0af..957364f 100644 --- a/changelog.md +++ b/changelog.md @@ -10,7 +10,7 @@ - Better dialog after editing paper [(#142)](https://github.com/pubs/pubs/issues/142) -- Add a command to open urls [(#139)](https://github.com/pubs/pubs/issues/139) +- Add a command to open urls ([#139](https://github.com/pubs/pubs/issues/139) *by [ksunden](https://github.com/ksunden)*) - More robust cache on version change [(#138)](https://github.com/pubs/pubs/issues/138) @@ -22,7 +22,7 @@ - Uses bibtexparser bwriter instead of internal encoder and adds `--ignore-fields` option to export. [(#106)](https://github.com/pubs/pubs/issues/106) -- Configurable alias descriptions [(#104)](https://github.com/pubs/pubs/issues/104) +- Configurable alias descriptions ([#104](https://github.com/pubs/pubs/issues/104) by [wflynny](https://github.com/wflynny)) - Support year ranges in query [(#102)](https://github.com/pubs/pubs/issues/102) @@ -49,9 +49,9 @@ - [[#103]](https://github.com/pubs/pubs/issues/103) Fixes unicode comparison [(#116)](https://github.com/pubs/pubs/issues/116) -- [[#95]](https://github.com/pubs/pubs/issues/95) robust handling of DOIs [(#105)](https://github.com/pubs/pubs/issues/105) +- [[#95]](https://github.com/pubs/pubs/issues/95) robust handling of DOIs ([#105](https://github.com/pubs/pubs/issues/105) by [wflynny](https://github.com/wflynny)) -- [[#99]](https://github.com/pubs/pubs/issues/99) Print help when no subcommand is provided [(#100)](https://github.com/pubs/pubs/issues/100) +- [[#99]](https://github.com/pubs/pubs/issues/99) Print help when no subcommand is provided ([#100](https://github.com/pubs/pubs/issues/100) by [wflynny](https://github.com/wflynny)) - Fix defaults not used in config. [(#97)](https://github.com/pubs/pubs/issues/97) diff --git a/readme.md b/readme.md index 1129229..4b03dcd 100644 --- a/readme.md +++ b/readme.md @@ -125,3 +125,4 @@ You can access the self-documented configuration by using `pubs conf`, and all t - [Tyler Earnest](https://github.com/tmearnest) - [Dennis Wilson](https://github.com/d9w) - [Bill Flynn](https://github.com/wflynny) +- [ksunden](https://github.com/ksunden) From bc239aba6905b0926fa90650489657141f39634f Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Tue, 31 Jul 2018 11:08:05 +0200 Subject: [PATCH 3/6] Removes italic on one contributor. --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 957364f..9b4e61b 100644 --- a/changelog.md +++ b/changelog.md @@ -10,7 +10,7 @@ - Better dialog after editing paper [(#142)](https://github.com/pubs/pubs/issues/142) -- Add a command to open urls ([#139](https://github.com/pubs/pubs/issues/139) *by [ksunden](https://github.com/ksunden)*) +- Add a command to open urls ([#139](https://github.com/pubs/pubs/issues/139) by [ksunden](https://github.com/ksunden)) - More robust cache on version change [(#138)](https://github.com/pubs/pubs/issues/138) From c76c7607f9d23484cb2adb8baca1f3c97a554cd2 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Wed, 1 Aug 2018 14:22:18 +0900 Subject: [PATCH 4/6] Upgrade pyfakefs to current version Fix #148. Also did some cleanup on the tests. --- pubs/uis.py | 3 +++ tests/fake_env.py | 19 ++++++++++++++----- tests/requirements.txt | 2 +- tests/test_bibstruct.py | 1 - tests/test_config.py | 2 +- tests/test_databroker.py | 5 ++--- tests/test_datacache.py | 1 - tests/test_pretty.py | 2 -- tests/test_usecase.py | 17 +++++++---------- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/pubs/uis.py b/pubs/uis.py index c2a8bfc..326ab25 100644 --- a/pubs/uis.py +++ b/pubs/uis.py @@ -46,6 +46,9 @@ def _get_local_editor(): def _editor_input(editor, initial='', suffix='.tmp'): """Use an editor to get input""" str_initial = initial.encode('utf-8') # TODO: make it a configuration item + # tfile_name = '/tmp/pubs.tmp' + # with open(tfile_name, 'w') as temp_file: + # temp_file.write(str_initial) with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as temp_file: tfile_name = temp_file.name temp_file.write(str_initial) diff --git a/tests/fake_env.py b/tests/fake_env.py index 4f8af1b..d8404a3 100644 --- a/tests/fake_env.py +++ b/tests/fake_env.py @@ -98,11 +98,20 @@ class TestFakeFs(fake_filesystem_unittest.TestCase): def setUp(self): self.rootpath = os.path.abspath(os.path.dirname(__file__)) + self.homepath = os.path.expanduser('~') self.setUpPyfakefs() - self.fs.CreateDirectory(os.path.expanduser('~')) - self.fs.CreateDirectory(self.rootpath) - os.chdir(self.rootpath) + self.reset_fs() + # self.fs.create_dir(os.path.expanduser('~')) + # self.fs.create_dir(self.rootpath) + # os.chdir(self.rootpath) + def reset_fs(self): - self._stubber.tearDown() # renew the filesystem - self.setUp() + if self.fs.isdir(self.homepath): + self.fs.remove_object(self.homepath) + if self.fs.isdir(self.rootpath): + self.fs.remove_object(self.rootpath) + + self.fs.create_dir(os.path.expanduser('~')) + self.fs.create_dir(self.rootpath) + os.chdir(self.rootpath) diff --git a/tests/requirements.txt b/tests/requirements.txt index 2790d94..f3726e3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ # those are the additional packages required to run the tests six -pyfakefs==3.3 +pyfakefs ddt mock diff --git a/tests/test_bibstruct.py b/tests/test_bibstruct.py index 7d56feb..05af028 100644 --- a/tests/test_bibstruct.py +++ b/tests/test_bibstruct.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import os import unittest import copy diff --git a/tests/test_config.py b/tests/test_config.py index 23856a2..cecd75b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,7 +2,7 @@ import unittest import dotdot -from pubs.config import conf +# from pubs.config import conf # class TestConfig(unittest.TestCase): # diff --git a/tests/test_databroker.py b/tests/test_databroker.py index 57e5c66..041ac8e 100644 --- a/tests/test_databroker.py +++ b/tests/test_databroker.py @@ -5,8 +5,7 @@ import os import dotdot import fake_env -from pubs import content, filebroker, databroker, datacache -from pubs.config import conf +from pubs import content, databroker, datacache import str_fixtures from pubs import endecoder @@ -35,7 +34,7 @@ class TestDataBroker(fake_env.TestFakeFs): self.assertEqual(db.pull_metadata('citekey1'), page99_metadata) pulled = db.pull_bibentry('citekey1')['Page99'] - for key, value in pulled.items(): + for key in pulled.keys(): self.assertEqual(pulled[key], page99_bibentry['Page99'][key]) self.assertEqual(db.pull_bibentry('citekey1'), page99_bibentry) diff --git a/tests/test_datacache.py b/tests/test_datacache.py index 4709aca..bfb9223 100644 --- a/tests/test_datacache.py +++ b/tests/test_datacache.py @@ -3,7 +3,6 @@ import unittest import time import dotdot -import fake_env from pubs.datacache import CacheEntrySet diff --git a/tests/test_pretty.py b/tests/test_pretty.py index 0d2cf23..0c09211 100644 --- a/tests/test_pretty.py +++ b/tests/test_pretty.py @@ -1,10 +1,8 @@ from __future__ import unicode_literals import unittest -import os import dotdot -import fake_env from pubs import endecoder, pretty, color, config diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 8091f69..2b4199c 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -15,14 +15,12 @@ from pyfakefs.fake_filesystem import FakeFileOpen import dotdot import fake_env -from pubs import pubs_cmd, update, color, content, filebroker, uis, p3, endecoder +from pubs import pubs_cmd, color, content, uis, p3, endecoder from pubs.config import conf -import configobj import str_fixtures import fixtures -from pubs.commands import init_cmd, import_cmd # makes the tests very noisy PRINT_OUTPUT = False @@ -66,12 +64,12 @@ class TestFakeInput(unittest.TestCase): def test_editor_input(self): other_input = fake_env.FakeInput(['yes', 'no'], - module_list=[uis, color]) + module_list=[uis]) other_input.as_global() - self.assertEqual(uis._editor_input(), 'yes') - self.assertEqual(uis._editor_input(), 'no') + self.assertEqual(uis._editor_input('fake_editor'), 'yes') + self.assertEqual(uis._editor_input('fake_editor'), 'no') with self.assertRaises(fake_env.FakeInput.UnexpectedInput): - color.input() + uis._editor_input() class CommandTestCase(fake_env.TestFakeFs): @@ -82,7 +80,6 @@ class CommandTestCase(fake_env.TestFakeFs): def setUp(self, nsec_stat=True): super(CommandTestCase, self).setUp() os.stat_float_times(nsec_stat) - # self.fs = fake_env.create_fake_fs([content, filebroker, conf, init_cmd, import_cmd, configobj, update], nsec_stat=nsec_stat) self.default_pubs_dir = os.path.expanduser('~/.pubs') self.default_conf_path = os.path.expanduser('~/.pubsrc') @@ -178,7 +175,7 @@ class URLContentTestCase(DataCommandTestCase): return p3.urlparse(url).path def url_exists(self, url): - return self.fs.Exists(self._url_to_path(url)) + return self.fs.exists(self._url_to_path(url)) def url_to_byte_content(self, url, ui=None): path = self._url_to_path(url) @@ -920,4 +917,4 @@ class TestCache(DataCommandTestCase): if __name__ == '__main__': - unittest.main() + unittest.main(verbosity=2) From cf97f681efe2ead29fa121df698ea286c4f6b336 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Wed, 1 Aug 2018 14:37:23 +0900 Subject: [PATCH 5/6] cleanup commented code, better reset_fs() --- pubs/uis.py | 3 --- tests/fake_env.py | 12 ++++-------- tests/test_databroker.py | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pubs/uis.py b/pubs/uis.py index 326ab25..c2a8bfc 100644 --- a/pubs/uis.py +++ b/pubs/uis.py @@ -46,9 +46,6 @@ def _get_local_editor(): def _editor_input(editor, initial='', suffix='.tmp'): """Use an editor to get input""" str_initial = initial.encode('utf-8') # TODO: make it a configuration item - # tfile_name = '/tmp/pubs.tmp' - # with open(tfile_name, 'w') as temp_file: - # temp_file.write(str_initial) with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as temp_file: tfile_name = temp_file.name temp_file.write(str_initial) diff --git a/tests/fake_env.py b/tests/fake_env.py index d8404a3..028d656 100644 --- a/tests/fake_env.py +++ b/tests/fake_env.py @@ -101,16 +101,12 @@ class TestFakeFs(fake_filesystem_unittest.TestCase): self.homepath = os.path.expanduser('~') self.setUpPyfakefs() self.reset_fs() - # self.fs.create_dir(os.path.expanduser('~')) - # self.fs.create_dir(self.rootpath) - # os.chdir(self.rootpath) - def reset_fs(self): - if self.fs.isdir(self.homepath): - self.fs.remove_object(self.homepath) - if self.fs.isdir(self.rootpath): - self.fs.remove_object(self.rootpath) + """Reset the fake filesystem""" + for dir_name in self.fs.listdir('/'): + if dir_name not in ['var', 'tmp']: + self.fs.remove_object(os.path.join('/', dir_name)) self.fs.create_dir(os.path.expanduser('~')) self.fs.create_dir(self.rootpath) diff --git a/tests/test_databroker.py b/tests/test_databroker.py index 041ac8e..8891931 100644 --- a/tests/test_databroker.py +++ b/tests/test_databroker.py @@ -90,4 +90,4 @@ class TestDataBroker(fake_env.TestFakeFs): if __name__ == '__main__': - unittest.main() + unittest.main(verbosity=2) From 9093cbfbed211274f36f3014a4037094c64459d7 Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Wed, 1 Aug 2018 14:39:15 +0200 Subject: [PATCH 6/6] Add changelog entry for #151. --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 9b4e61b..1a3267b 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,8 @@ ### Fixed bugs +- [[#148]](https://github.com/pubs/pubs/issues/148) Fix compatibility with Pyfakefs 3.7 [(#151)](https://github.com/pubs/pubs/pull/151) + - [[#95]](https://github.com/pubs/pubs/issues/95) Error message when editor is missing [(#141)](https://github.com/pubs/pubs/issues/141) - Fixes tests for printing help on `--help` and without argument. [(#137)](https://github.com/pubs/pubs/issues/137)