Commit graph

59 commits

Author SHA1 Message Date
Micah Jerome Ellison
d15e683955 Update search features to use new steps
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
3ddfb4d594 Implement editor-related steps in pytest-bdd
- Implement mock editor fixture
- Add fixture to keep track of editor state
- Implement various steps to check editor state

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
ce64d7973b Implement @skip_win and @skip_editor
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
36dc01bf30 Fixing custom template test and skipping some broken tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
148d3fdb18 Update test w/ new steps
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
11e0e84dcf Fix test failing from lack of whitespace
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
430182a0a5 Implement JSON tests and remove "node" nomenclature from tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
48c9d9fa16 Implement tag tests in JSON
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
3cc3e387c5 Combine JSON and XML parsing tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
ef6ed93ecd Add JSON parsing test and combine it with XML parsing test
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
b8c7a7c7e5 Add format tests to pytest-bdd
- Implement cache dir fixture and step
- Implement various steps to check the cache directory (files contained,
  etc)

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
e2bb8cf0de Add encryption test to pytest-bdd
- Clean up some formatting

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
3d3bd91700 Expand "we run" step to handling input better
- Use regex parser in pytest-bdd to support "we run" steps that also
  have user input ("and enter")

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
e720430aa4 Implement "should" and "should not" handling
- Handling should and should not like this should reduce the amount of
  fixtures we need for the test suite
- Add more password tests

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
c76ee8cd4f Add more password tests to pytest-bdd
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
10b604ef89 Add more password tests to pytest-bdd
- Fix some input handling in steps (especially for passwords)
- Fix some formatting issues

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
6b27126c37 Implement password prompt steps in pytest-bdd
- Scaffold some tests that will be added later
- Add fixtures for journal name and keyring type
- Add "we should be prompted for a password" step
- Add "we should not be prompted for a password" step

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
d0f92113f4 Add no keyring encryption test to pytest-bdd
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
fe018ee241 Implement test keyrings and add password tests
- Implement TestKeyring
- Implement NoKeyring
- Implement FailedKeyring
- Copy in `read_value_from_string` function from old tests (will
  probably rewrite this later)
- Add fixtures for keyrings
- Implement "we have a keyring" step
- Implement step to check specific config values for tests

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
1c78a30535 Fix bug in makefile
- Makefile no longer runs on virtual env modules
- Update some function names so pyflakes doesn't error

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
921ebdcdd5 Update mocks in "we run" step
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
5ad5bac786 Standardize line breaks in datetime tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
40a1a871cb Migrate the rest of the delete tests from behave to pytest bdd
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
8754837f15 Add some functioning delete tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
7ccadebca0 Finish migrating datetime.feature to pytest bdd
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
a529ee5d06 Add another unreadable/readable date test
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
0c9b6cf85f Add unreadable date test
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
f686e2b9f0 Fix local config overwrite when running pytest bdd
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
7e6dd354cf Add unreadable date test
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
7d04fb904a Add abbreviated weekday test
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
72170304ef Expand "we run" step in pytest-bdd
- Add some necessary fixtures
- Add datetime test
- Implement "the output should not contain" step
- Implement "the output should contain the date" step

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
74ae5f039b Rename test functions for clarity
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
be05f96c26 Implement "the output should be" step
- Add another datetime test

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
e257194d17 Add scenario outline test to datetime
- Allow config step to support scenario outlines
- Add another datetime test
- Get rid of read journal step since it doesn't work with other journal
  types (we should rely on jrnl knowing how to parse each jrnl type for
  better tests)

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
7974f30261 Make tests move into temp dir as they run
This will prevent any unexpected files from showing up anywhere outside
the temp dir

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
c500730ae6 Implement and add datetime tests
- Deletes most of the datetime tests so that they can be
  re-added as they are implemented in pytest-bdd
- Implements steps that check the journal and output for strings
- Get rid of deployment tag (we're not using it, anyway)

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
7657bd7221 Implement version-checking test
- Add new step definition

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
3055cca767 Add tests for core feature to pytest-bdd
- Implement "the output should contain" step

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
0b50ae1be0 Rename features directory to data
This is more inline with pytest standards

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
530190df7a Implement handling of temp and working dirs
Pytest-bdd uses fixtures to handle most things. This makes a fixture
that will create a temp directory for the tests to run in.

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Jonathan Wren
1390493a29 Install pytest-bdd (which will eventually replace behave)
- Copy over the current tests from behave into the new directory that
  pytest-bdd will use them in

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2021-07-03 15:49:18 -07:00
Micah Jerome Ellison
e84bb603eb
Ensure that line endings in all py files are Linux style instead of Windows (#1250) 2021-06-05 13:15:17 -07:00
Suhas
dd74b14d76
More graceful handling of low linewrap values (#1219)
* behavior outline

* enforce positive initial linewrap

Check column widths

update gitignore

throw error when linewrap too small

simply check for large enough linewrap value

* delete unused error message

* PR feedback

make exception more informative

update check_linewrap signature in src and test

make check_linewrap a free function

* delete unused function

* delete else..pass block

* newline for make format
2021-04-10 16:49:56 -07:00
Suhas
a3f4f6b944
Fix bug that prevented --format pretty and --format short from working (#1177) 2021-03-06 10:47:03 -08:00
Suhas
4f79803885
Allow runtime configuration overrides from the commandline (#1169)
Add --config-override feature

* add test and argument handler for runtime override of configurations.
* identify location to apply override in "main"
* update gitignore
* remove unneeded import
* add jrnl interface test for overriden configurations
* trivial whitespace change
* implement runtime override
* make format
* refactor override unittest
* clean up unused import
* start writing integration test
* add linewrap override scenario
* implement editor override step
* add dev dependencies on pytest -mock and -cov
* make format
* remove unused imports
* make format
* rename --override to --config-override
* move override implementation into own module
* begin TDD of dot notated overrides
* rewrite behavior scenario
* implement recursive config overrides
* clean up unittests
* iterate on behave step
* make format
* cleanup
* move override behave tests out of core
* refactor recursive code
* make format
* code cleanup
* remove unused import
* update test config
* rewrite test for better mock call expect
* make format
* binary search misbehaving windows test
* unittest multiple overrides
* uncomment dot notation unittest
* add multiple override scenario spec
* make format
* make format
* update unittests for new syntax
* update integ tests for new syntax
* update gitignore
* guard override application
* deserialize function as return type
* make format
* organize deserialization unittests
* better, more specific behave tests
* test different editor launch commands
* formatting
* handle datatypes in deserialization and update helptext
* stick to config convention in testbed
* update tests ith better verifications
* make format
* space
* review feedbac
* make format
* skip on win
* update deps
* update tests with better verifications
make format
space
review feedbac
* skip on win
* update deps
* refactor deserialization
organize test_parse_args
make format
* skip on win
* refactor deserialization
organize test_parse_args
make format
* update tests ith better verifications
* make format
* space
* make format
* document apply_overrides
* update gitignore
* document config-override enhancement
* Simplify config override syntax (#5)
* update tests and expected behavior
* clean up arg parsing tests
* update deserialization
* update deserialization
* config argparse action
* update override application logic
* update tests; delete unused imports
* override param must be list
* update docstring
* update test input to SUT
* update remaining override unittests
* make format
* forgot to update CLI syntax
* update documentation to sphinx style
* variable renames
* Lockfile merge (#7)
* Add brew and gitter badges to README
* Update changelog [ci skip]
* Make journal selection behavior more consistent when there's a colon with no date (#1164)
* Simplify config override syntax (#8)
* update tests and expected behavior
* clean up arg parsing tests
* update deserialization
* update deserialization
* config argparse action
* update override application logic
* update tests; delete unused imports
* override param must be list
* update docstring
* update test input to SUT
* update remaining override unittests
* make format
* forgot to update CLI syntax
* formatting
* Update pyproject.toml
* update lockfile to remove pytest-cov and pytest-mock deps
* update docs
* reuse existing mock; delete unneeded code
* move overrides earlier in the execution
use existing configs instead of custom
make format
clean up imports
* update for passworded access
context.parser -> parsed_args
* test that no editor is launched
* remove unnecessary mocks
* rename variable for intent
* reinstate getpass deletion
* update gitignore
* capture failure mode
* remove unneeded imports
* renamed variable
* delete redundant step
* comment on step
* clean up step behavior description
* [WIP] lock down journal access behavior
* skip -> wip
* correct command for overriding journal via dot keys
* update wip test for updating a "temp" journal and then reading baack its entries
* remove "mock" from poetry file
* make CI happy
* complex behavior sequence for default journal override
* separate out smaller pieces of logic
test that apply_overrides acts on base configuration and not the copy
* defer modification of loaded configuration to update_config
remove unused fixtures
delete complicated UT since behavior is covered in overrides.feature integ test
delete redundant UT
* Update .gitignore
* remove skip_win
* forward override unpacking to yaml library
* merge config override step with existing config_var step in core
delete config_override step
unify step description syntax
* delete unused and redundant code
* rebases are hard
* remove wip tag from test
* remove skipped tests for windows
* Address code review
yield -> return
remove needless copy
adjust spacing
re-inline args return
reset packaging info to e6c0a16342
revert package version for this PR
* consolidate imports
* Defer config_override unpacking to dict *after* base config is loaded
store cli overrides without unpacking just yet
move deserialize_config_args to config module
delete custom Action class for config operations
apply [k,v] -> {k, v} for each override
update test data
update import
* rename deserialize_config_args to better express intent
make format
2021-03-02 18:47:57 -08:00
Micah Jerome Ellison
9e6cd8820f
Fix OS compatibility issues for editors with spaces, slashes, and quotes (#1153)
* Fix inverted POSIX check, refactor os_compat, and add tests for it
* Fix missing parentheses and remove skip_win on test that is passing in Windows now
* Fix expected quotes in quoted args
* Make  output clearer on failing test
* Bringing skip_win back to test whose failure is a bit more complicated than expected
2021-01-16 15:19:11 -08:00
Karim Rahal
f0e8fa2060
Add new -today-in-history, -month, -day, and -year search filters (#1145)
* Introduce -reminisce, -month, -day, and -year
* Update expected_args in parse_args tests
* Add check before creating compare_d
* Misc changes
* Implement testing for -month, -day, -year, and -reminisce
* Compress tests into one Scenario Outline
* Fix failing tests by updating dates_similar journal
* Create 'we set current date and time to' step
* Use time.parse in reminisce
* Update dates_similar journal
* Make 'Searching in a journal' test shorter
* Lint
* Implement reminiscing test
* Add combination tests
* Finalize tests
* Finalize pytests
* Simplify reminisce tests
* Change reminsice help (since it also shows today's entries)
* Re-do tests; use various tests
* Remove old test data
* Better scenario description
* Standardize format for compare_d
* Rename -reminisce to -today-in-history
2021-01-16 14:55:27 -08:00
Micah Jerome Ellison
c155bafa84
Notify user when config directory can't be created because there is already a file with the same name (#1134)
* Moving configuration values and methods from install.py to config.py -- everything is broken right now
* Using context to store config path - still lots broken
* Use mocks and context.config_path to store test configs - many tests still broken though
* Update changelog [ci skip]
* Fix jrnl --ls crash
* Fix crash when no editor configured
* Attempt to patch config path with test data - doesn't appear to be working
* Properly use patched config path and add config given to scenario that wasn't using it
* Fix copypasta
* Fix editor test that needed patched config and trapping for system exit
* Add exception and handling for when configuration directory is actually a file
* Remove extraneous comment
* Use more generic JrnlError with messaging switchboard
* Format code a bit nicer
* Remove unnecessary given in diagnostic test
* Ensure full error message is output
* Remove unnecessary whitespace characters
2021-01-02 15:19:44 -08:00
Micah Jerome Ellison
48cde1b473
Check for readline module instead of Windows when initializing autocomplete in install (#1104) 2020-12-04 15:13:38 -08:00
Micah Jerome Ellison
c38c39efee
Update dependencies - pyxdg, pytest, black (#1076)
* Update version pin on pyxdg and run poetry update
* Update pytest pin and rerun poetry update
* Update black pin to latest version, poetry update, and make format
2020-11-14 12:42:34 -08:00