gh-98 Check parsed metadata header in text file for type of dict
This commit is contained in:
parent
e27fb951bc
commit
479452b31c
|
@ -119,6 +119,7 @@ class Text(Base):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parsed_json = loads(first_line)
|
parsed_json = loads(first_line)
|
||||||
|
if isinstance(parsed_json, dict):
|
||||||
self.metadata_line = parsed_json
|
self.metadata_line = parsed_json
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if(constants.debug is True):
|
if(constants.debug is True):
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
1234567890
|
||||||
|
|
||||||
|
|
||||||
|
See gh-98
|
|
@ -72,6 +72,16 @@ def test_get_date_taken_from_invalid():
|
||||||
|
|
||||||
assert date_taken == expected_date_taken, date_taken
|
assert date_taken == expected_date_taken, date_taken
|
||||||
|
|
||||||
|
def test_get_metadata_with_numeric_header():
|
||||||
|
# See gh-98 for details
|
||||||
|
text = Text(helper.get_file('valid-with-numeric-header.txt'))
|
||||||
|
|
||||||
|
# Should not throw error
|
||||||
|
# TypeError: argument of type 'int' is not iterable
|
||||||
|
metadata = text.get_metadata()
|
||||||
|
|
||||||
|
assert metadata['mime_type'] == 'text/plain'
|
||||||
|
|
||||||
def test_set_album():
|
def test_set_album():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue