From b986485dd52759d6f99724ae6a1f5a5f347ec7d0 Mon Sep 17 00:00:00 2001 From: rachmadaniHaryono Date: Sun, 28 Apr 2019 14:00:46 +0800 Subject: [PATCH] new: test: convert_bookmark_set --- tests/test_buku.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test_buku.py b/tests/test_buku.py index 767da08..d7b253c 100644 --- a/tests/test_buku.py +++ b/tests/test_buku.py @@ -727,3 +727,39 @@ def test_copy_to_clipboard(platform, params): m_popen_retval.communicate.assert_called_once_with(content) else: m_popen.assert_not_called() + + +@pytest.mark.parametrize('export_type, exp_res', [ + [ + 'html', + '\n\n' + '\n' + 'Bookmarks\n

Bookmarks

\n\n

\n' + '

Buku bookmarks

\n' + '

\n' + '

\n' + '
Google\n' + '

\n

' + ], + ['org', '- [Untitled](htttp://example.com)\n- [Google](http://google.com)\n'], + ['markdown', '- [Untitled](htttp://example.com)\n- [Google](http://google.com)\n'], + ['random', None], +]) +def test_convert_bookmark_set(export_type, exp_res, monkeypatch): + from buku import convert_bookmark_set + import buku + bms = [ + (1, 'htttp://example.com', '', ',', '', 0), + (2, 'http://google.com', 'Google', ',', '', 0)] + if export_type == 'random': + with pytest.raises(AssertionError): + convert_bookmark_set(bms, export_type=export_type) + else: + + def return_fixed_number(): + return 1556430615 + monkeypatch.setattr(buku.time, 'time', return_fixed_number) + res = convert_bookmark_set(bms, export_type=export_type) + assert res['count'] == 2 + assert exp_res == res['data'] +