nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 028fa3e0daa3b0c8aa3fddd1461e9b3f7f4eb18d
parent b5d29db4c74b72115fa7e128454672e0899bac57
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Thu, 13 Sep 2018 05:57:13 -0400

Test nncli module through cli_dump_notes

Ref #8

Diffstat:
Mtests/test_nncli.py | 47++++++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)

diff --git a/tests/test_nncli.py b/tests/test_nncli.py @@ -73,17 +73,46 @@ def test_cli_list_notes(mocker, mock_nncli): nn_obj = nncli.nncli.Nncli(False) mocker.patch.object(nn_obj.ndb, 'filter_notes', new=mocker.Mock(return_value=test_note)) - print(nn_obj.ndb.filter_notes) nn_obj.cli_list_notes(False, 'test_search_string') nncli.nncli.print.assert_called_once_with('test_key [flg] test_title') - -@pytest.mark.skip -def test_cli_note_dump(): - pass - -@pytest.mark.skip -def test_cli_dump_notes(): - pass + nncli.utils.get_note_flags.assert_called_once() + nncli.utils.get_note_title.assert_called_once() + +def test_cli_note_dump(mocker, mock_nncli): + test_note = {'modified': 12345, + 'id': 1, + 'localkey': 1, + 'content': 'test_content'} + mocker.patch('nncli.utils.get_note_flags', + new=mocker.Mock(return_value='flg')) + mocker.patch('nncli.utils.get_note_title', + new=mocker.Mock(return_value='test_title')) + mocker.patch('nncli.utils.get_note_category', + new=mocker.Mock(return_value='test_category')) + mocker.patch('nncli.nncli.print') + nn_obj = nncli.nncli.Nncli(False) + mocker.patch.object(nn_obj.ndb, 'get_note', + new=mocker.Mock(return_value=test_note)) + nn_obj.cli_note_dump(1) + assert nncli.nncli.print.call_count == 8 + nn_obj.ndb.get_note.assert_called_once_with(1) + nncli.utils.get_note_flags.assert_called_once_with(test_note) + nncli.utils.get_note_title.assert_called_once_with(test_note) + nncli.utils.get_note_category.assert_called_once_with(test_note) + +def test_cli_dump_notes(mocker, mock_nncli): + test_notes = ( + [nncli.utils.KeyValueObject(key=1, + note={'key': 1})], + [], + [] + ) + nn_obj = nncli.nncli.Nncli(False) + mocker.patch.object(nn_obj.ndb, 'filter_notes', + new=mocker.Mock(return_value=test_notes)) + mocker.patch.object(nn_obj, 'cli_note_dump') + nn_obj.cli_dump_notes(False, 'test_search_string') + nn_obj.cli_note_dump.assert_called_once_with(1) @pytest.mark.skip def test_cli_note_create():