Merge pull request #60 from wheresmyjetpack/tests
Two tests, minor method call fix
This commit is contained in:
commit
0d0617258e
2
buku
2
buku
@ -744,6 +744,8 @@ class BukuDb:
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
logger.error('Index out of bound')
|
logger.error('Index out of bound')
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def delete_all_bookmarks(self):
|
def delete_all_bookmarks(self):
|
||||||
"""Should only be called inside of delete_bookmark
|
"""Should only be called inside of delete_bookmark
|
||||||
Drops the bookmark table if it exists
|
Drops the bookmark table if it exists
|
||||||
|
@ -6,6 +6,7 @@ import imp
|
|||||||
import os
|
import os
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
import unittest, pytest
|
import unittest, pytest
|
||||||
|
from unittest import mock
|
||||||
from os.path import join, expanduser
|
from os.path import join, expanduser
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
@ -212,6 +213,20 @@ class TestBukuDb(unittest.TestCase):
|
|||||||
from_db = bdb.get_bookmark_by_index(index)
|
from_db = bdb.get_bookmark_by_index(index)
|
||||||
self.assertIsNone(from_db)
|
self.assertIsNone(from_db)
|
||||||
|
|
||||||
|
# @unittest.skip('skipping')
|
||||||
|
def test_delete_bookmark_yes(self):
|
||||||
|
bdb = BukuDb()
|
||||||
|
# checking that "y" response causes delete_bookmark to return True
|
||||||
|
with mock.patch('builtins.input', return_value='y'):
|
||||||
|
self.assertTrue(bdb.delete_bookmark(0))
|
||||||
|
|
||||||
|
# @unittest.skip('skipping')
|
||||||
|
def test_delete_bookmark_no(self):
|
||||||
|
bdb = BukuDb()
|
||||||
|
# checking that non-"y" response causes delete_bookmark to return None
|
||||||
|
with mock.patch('builtins.input', return_value='n'):
|
||||||
|
self.assertIsNone(bdb.delete_bookmark(0))
|
||||||
|
|
||||||
# @unittest.skip('skipping')
|
# @unittest.skip('skipping')
|
||||||
def test_delete_all_bookmarks(self):
|
def test_delete_all_bookmarks(self):
|
||||||
bdb = BukuDb()
|
bdb = BukuDb()
|
||||||
@ -284,7 +299,7 @@ def test_print_bookmark(capsys, caplog, setup):
|
|||||||
bdb.print_bookmark(1)
|
bdb.print_bookmark(1)
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
|
|
||||||
for record in caplog.records:
|
for record in caplog.records():
|
||||||
assert record.levelname == "ERROR"
|
assert record.levelname == "ERROR"
|
||||||
assert record.getMessage() == "No matching index"
|
assert record.getMessage() == "No matching index"
|
||||||
assert (out, err) == ('', '')
|
assert (out, err) == ('', '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user