Skip to content

Commit

Permalink
gh-98 Check parsed metadata header in text file for type of dict
Browse files Browse the repository at this point in the history
  • Loading branch information
jmathai committed Apr 20, 2016
1 parent e27fb95 commit 71a0b1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion elodie/media/text.py
Expand Up @@ -119,7 +119,8 @@ def parse_metadata_line(self):

try:
parsed_json = loads(first_line)
self.metadata_line = parsed_json
if isinstance(parsed_json, dict):
self.metadata_line = parsed_json
except ValueError:
if(constants.debug is True):
print 'Could not parse JSON from first line: %s' % first_line
Expand Down
4 changes: 4 additions & 0 deletions elodie/tests/files/valid-with-numeric-header.txt
@@ -0,0 +1,4 @@
1234567890


See gh-98
10 changes: 10 additions & 0 deletions elodie/tests/media/text_test.py
Expand Up @@ -72,6 +72,16 @@ def test_get_date_taken_from_invalid():

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():
temporary_folder, folder = helper.create_working_folder()

Expand Down

0 comments on commit 71a0b1b

Please sign in to comment.