Skip to content

Commit

Permalink
Fix build break
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Feb 12, 2023
1 parent 19b690f commit f00348e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions buku
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,7 @@ class BukuDb:
else:
newtag = None
resp = 'y'
add_parent_folder_as_tag = (resp == 'y')
add_parent_folder_as_tag = resp == 'y'

resp = 'y'

Expand Down Expand Up @@ -2622,7 +2622,7 @@ class BukuDb:
resp = input('Add parent folder names as tags? (y/n): ')
else:
resp = 'y'
add_bookmark_folder_as_tag = (resp == 'y')
add_bookmark_folder_as_tag = resp == 'y'
try:
with open(filepath, 'r', encoding='utf-8') as datafile:
data = json.load(datafile)
Expand Down
2 changes: 1 addition & 1 deletion bukuserver/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get(self, tag: T.Optional[str]):
tags = search_tag(db=bukudb, stag=tag)
if tag not in tags[1]:
raise exceptions.NotFound()
return dict(name=tag, usage_count=tags[1][tag])
return {"name": tag, "usage_count": tags[1][tag]}

def put(self, tag: str):
bukudb = get_bukudb()
Expand Down
4 changes: 2 additions & 2 deletions bukuserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def _saved(self, id, url, ok=True):
if id and ok:
session['saved'] = id
else:
raise Exception('Duplicate URL' if self.model.bukudb.get_rec_id(url) not in [id, None] else
'Rejected by the database')
raise ValueError('Duplicate URL' if self.model.bukudb.get_rec_id(url) not in [id, None] else
'Rejected by the database')

def _apply_filters(self, models, filters):
for idx, _, value in filters:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_bukuDb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,11 @@ def test_delete_rec_on_empty_database(setup, index, is_range, low, high):
@pytest.mark.parametrize(
"kwargs, exp_res, raise_error",
[
[dict(index="a", low="a", high=1, is_range=True), None, True],
[dict(index="a", low="a", high=1, is_range=False), None, True],
[dict(index="a", low=1, high="a", is_range=True), None, True],
[dict(index="a", is_range=False), None, True],
[dict(index="a", is_range=True), None, True],
[{"index": 'a', "low": 'a', "high": 1, "is_range": True}, None, True],
[{"index": 'a', "low": 'a', "high": 1, "is_range": False}, None, True],
[{"index": 'a', "low": 1, "high": 'a', "is_range": True}, None, True],
[{"index": 'a', "is_range": False}, None, True],
[{"index": 'a', "is_range": True}, None, True],
],
)
def test_delete_rec_on_non_integer(
Expand Down Expand Up @@ -1136,9 +1136,9 @@ def test_update_rec_index_0(caplog):
@pytest.mark.parametrize(
"kwargs, exp_res",
[
[dict(index=1), False],
[dict(index=1, url="url"), False],
[dict(index=1, url=""), False],
[{"index": 1}, False],
[{"index": 1, "url": 'url'}, False],
[{"index": 1, "url": ''}, False],
],
)
def test_update_rec(tmp_path, kwargs, exp_res):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ def test_get_tiny_url(client, url, exp_res, status_code):

@pytest.mark.parametrize('kwargs, status_code, exp_res', [
[
dict(data={'url': 'http://google.com'}),
{"data": {'url': 'http://google.com'}},
200,
{
'bad url': 0, 'recognized mime': 0,
'tags': None, 'title': 'Google'}
],
[{}, 400, response_template['failure']],
[
dict(data={'url': 'chrome://bookmarks/'}),
{"data": {'url': 'chrome://bookmarks/'}},
200,
{
'bad url': 1, 'recognized mime': 0,
Expand All @@ -199,8 +199,8 @@ def test_network_handle(client, kwargs, status_code, exp_res):
def test_bookmark_range_api(client):
status_code = 200
kwargs_list = [
dict(data={'url': 'http://google.com'}),
dict(data={'url': 'http://example.com'})]
{"data": {'url': 'http://google.com'}},
{"data": {'url': 'http://example.com'}}]
for kwargs in kwargs_list:
rd = client.post('/api/bookmarks', **kwargs)
assert rd.status_code == status_code
Expand Down

1 comment on commit f00348e

@jarun
Copy link
Owner Author

@jarun jarun commented on f00348e Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeXofLeviafan @rachmadaniHaryono can you please review these changes?

Also there are some more left in views.py:

bukuserver/views.py:194:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
bukuserver/views.py:223:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
bukuserver/views.py:392:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
bukuserver/views.py:550:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
bukuserver/views.py:569:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)

Please fix those.

Please sign in to comment.