Feature/fix buku test (#423)
* fix pylint * chg: tests: update tox - add envlist for py38, flake8, and pylint - let tox install required package * chg: test: remove expected error * chg: test: remove impossible case * fix: test: delete rec index test
This commit is contained in:
parent
b95ea885d1
commit
467d865e42
@ -12,7 +12,6 @@ import sys
|
||||
import urllib
|
||||
import zipfile
|
||||
from genericpath import exists
|
||||
from itertools import product
|
||||
from tempfile import TemporaryDirectory, NamedTemporaryFile
|
||||
|
||||
from unittest import mock
|
||||
@ -64,7 +63,7 @@ def setup():
|
||||
os.remove(TEST_TEMP_DBFILE_PATH)
|
||||
|
||||
|
||||
class PrettySafeLoader(yaml.SafeLoader): # pylint: disable=too-many-ancestors
|
||||
class PrettySafeLoader(yaml.SafeLoader): # pylint: disable=too-many-ancestors,too-few-public-methods
|
||||
def construct_python_tuple(self, node):
|
||||
return tuple(self.construct_sequence(node))
|
||||
|
||||
@ -779,7 +778,6 @@ def test_compactdb(setup):
|
||||
)
|
||||
@example(low=0, high=0, delay_commit=False, input_retval='y')
|
||||
@settings(max_examples=2, deadline=None)
|
||||
@unittest.skip('skipping')
|
||||
def test_delete_rec_range_and_delay_commit(setup, low, high, delay_commit, input_retval):
|
||||
"""test delete rec, range and delay commit."""
|
||||
bdb = BukuDb()
|
||||
@ -824,8 +822,7 @@ def test_delete_rec_range_and_delay_commit(setup, low, high, delay_commit, input
|
||||
return
|
||||
if (low == 0 or high == 0) and input_retval == 'y':
|
||||
assert res == exp_res
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
bdb.get_rec_all()
|
||||
assert len(bdb_dc.get_rec_all()) == 0
|
||||
# teardown
|
||||
os.environ['XDG_DATA_HOME'] = TEST_TEMP_DIR_PATH
|
||||
return
|
||||
@ -846,34 +843,18 @@ def test_delete_rec_range_and_delay_commit(setup, low, high, delay_commit, input
|
||||
os.environ['XDG_DATA_HOME'] = TEST_TEMP_DIR_PATH
|
||||
|
||||
|
||||
@only_python_3_5
|
||||
@pytest.mark.skip(reason='Impossible case.')
|
||||
@pytest.mark.parametrize(
|
||||
'low, high',
|
||||
product(
|
||||
[1, MAX_SQLITE_INT + 1],
|
||||
[1, MAX_SQLITE_INT + 1],
|
||||
)
|
||||
'index, delay_commit, input_retval',
|
||||
[
|
||||
[-1, False, False],
|
||||
[0, False, False],
|
||||
[1, False, True],
|
||||
[1, False, False],
|
||||
[1, True, True],
|
||||
[1, True, False],
|
||||
[100, False, True],
|
||||
]
|
||||
)
|
||||
def test_delete_rec_range_and_big_int(setup, low, high):
|
||||
"""test delete rec, range and big integer."""
|
||||
bdb = BukuDb()
|
||||
index = 0
|
||||
is_range = True
|
||||
|
||||
# Fill bookmark
|
||||
for bookmark in TEST_BOOKMARKS:
|
||||
bdb.add_rec(*bookmark)
|
||||
db_len = len(TEST_BOOKMARKS)
|
||||
res = bdb.delete_rec(index=index, low=low, high=high, is_range=is_range)
|
||||
if high > db_len and low > db_len:
|
||||
assert not res
|
||||
return
|
||||
assert res
|
||||
|
||||
|
||||
@given(index=st.integers(), delay_commit=st.booleans(), input_retval=st.booleans())
|
||||
@unittest.skip('skipping')
|
||||
def test_delete_rec_index_and_delay_commit(index, delay_commit, input_retval):
|
||||
"""test delete rec, index and delay commit."""
|
||||
bdb = BukuDb()
|
||||
@ -886,11 +867,6 @@ def test_delete_rec_index_and_delay_commit(index, delay_commit, input_retval):
|
||||
|
||||
n_index = index
|
||||
|
||||
if index.bit_length() > 63:
|
||||
with pytest.raises(OverflowError):
|
||||
bdb.delete_rec(index=index, delay_commit=delay_commit)
|
||||
return
|
||||
|
||||
with mock.patch('builtins.input', return_value=input_retval):
|
||||
res = bdb.delete_rec(index=index, delay_commit=delay_commit)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import json
|
||||
|
||||
from click.testing import CliRunner
|
||||
import flask
|
||||
import pytest
|
||||
import flask
|
||||
from click.testing import CliRunner
|
||||
|
||||
from bukuserver import server
|
||||
from bukuserver.response import response_template
|
||||
|
@ -1,7 +1,7 @@
|
||||
from argparse import Namespace
|
||||
|
||||
from flask import current_app
|
||||
import pytest
|
||||
from flask import current_app
|
||||
|
||||
from buku import BukuDb
|
||||
from bukuserver import server
|
||||
|
39
tox.ini
39
tox.ini
@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = python35,python36,python37
|
||||
envlist = python35,python36,python37,python38,pylint,flake8
|
||||
|
||||
[flake8]
|
||||
max-line-length = 139
|
||||
@ -26,10 +26,37 @@ ignore =
|
||||
W504,
|
||||
|
||||
[testenv]
|
||||
usedevelop = true
|
||||
deps = pytest
|
||||
|
||||
[testenv:python35]
|
||||
extras = tests
|
||||
commands =
|
||||
pytest --cov buku -vv -m "not non_tox" {posargs}
|
||||
|
||||
[testenv:python36]
|
||||
extras = tests
|
||||
commands =
|
||||
pytest --cov buku -vv -m "not non_tox" {posargs}
|
||||
|
||||
[testenv:python37]
|
||||
extras = tests
|
||||
commands =
|
||||
pytest --cov buku -vv -m "not non_tox" {posargs}
|
||||
|
||||
[testenv:python38]
|
||||
extras = tests
|
||||
commands =
|
||||
pytest --cov buku -vv -m "not non_tox" {posargs}
|
||||
|
||||
[testenv:pylint]
|
||||
deps = pylint
|
||||
whitelist_externals =
|
||||
/usr/bin/find
|
||||
commands =
|
||||
pip install -e .[tests]
|
||||
pip install -r requirements.txt
|
||||
python -m flake8
|
||||
pylint --rcfile tests/.pylintrc buku
|
||||
find . -iname "*.py" -not -path "./.tox/*" -not -path "./build/*" -exec pylint --rcfile tests/.pylintrc \{\} +
|
||||
pytest --cov buku -vv {posargs}
|
||||
|
||||
[testenv:flake8]
|
||||
deps = flake8
|
||||
commands =
|
||||
python -m flake8
|
||||
|
Loading…
Reference in New Issue
Block a user