FIX(buku) ff json import folder w/o children

- fixes jarun/Buku#340
- replaced error with warning
- proper warning message added
- test added
This commit is contained in:
Chris Drexler 2018-12-30 14:12:49 +01:00
parent f316f9b980
commit 727141b5e2
2 changed files with 22 additions and 3 deletions

6
buku
View File

@ -3027,7 +3027,7 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
.format(bm_entry['uri'], bm_entry['title'], tags, desc))
yield (bm_entry['uri'], bm_entry['title'], tags, desc, 0, True, False)
except Exception as e:
LOGERR(e)
LOGERR("Error parsing entry '{}' Exception '{}'".format(bm_entry['title'], e))
elif TypeCode.folder.value == typeCode:
try:
@ -3037,9 +3037,9 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
for entry in iterate_children(
parent_folder+"/"+bm_entry['title'], bm_entry['children']):
yield entry
except Exception as e:
except Exception:
# if any of the properties does not exist, bail out silently
LOGERR(e)
LOGDBG("No 'children' found in bookmark folder - skipping: {}".format(bm_entry['title']))
elif TypeCode.separator.value == typeCode:
LOGDBG("Unknown typeCode found : {}".format(typeCode))

View File

@ -110,6 +110,25 @@ def test_load_invalid_typecode():
assert len(result) == 0
def test_load_folder_with_no_children():
"""test method."""
# Arrange
data = json.loads("""
{
"title" : "title",
"typeCode" : 2
} """)
# Act
items = import_firefox_json(data)
# Assert
result = []
for item in items:
result.append(item)
assert 0 == len(result)
def test_load_one_child():
"""test method."""