Skip to content

Commit

Permalink
Fixed the quotes test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 13, 2014
1 parent 6bcf7f9 commit 8c197fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
10 changes: 9 additions & 1 deletion doorstop/core/importer.py
Expand Up @@ -227,7 +227,7 @@ def _itemize(header, data, document, mapping=None):
identifier = value
elif key == 'links':
# split links into a list
attrs[key] = [p for p in LIST_SEP_RE.split(value) if p]
attrs[key] = _split_list(value)
else:
attrs[key] = value

Expand All @@ -251,6 +251,14 @@ def _itemize(header, data, document, mapping=None):
logging.warning(exc)


def _split_list(value):
"""Split a string list into parts."""
if value:
return [p for p in LIST_SEP_RE.split(value) if p]
else:
return []


# Mapping from file extension to file reader
FORMAT_FILE = {'.csv': _file_csv,
'.tsv': _file_tsv,
Expand Down
8 changes: 4 additions & 4 deletions doorstop/core/test/files/exported-modified.csv
Expand Up @@ -3,10 +3,10 @@ REQ0555,1.2.3,"Hello, world!
",,"SYS001,
SYS002",True,"False",FALSE,
REQ003,1.4,"Hello, world!
",REF123,REQ001,false,"FALSE",True,''
",REF123,REQ001,false,"FALSE",True,"Some ""quoted"" text 'here'."
REQ004,1.6,"Hello, world!
",,,FAlSe,tRue,"TRUE",DOORSTOP RULES!!
",,,FAlSe,tRue,"TRUE",
REQ002,2.1,"Hello, world!
",,,"true",False,"True","Hey, I've got some text. The "Back" button should be 'bold'. I said "failure's"."
",,,"true",False,"True",""
REQ2-001,2.1,"Hello, world!
",,REQ001,True,"false",True,"Is alive?
",,REQ001,True,"false",True,""
9 changes: 5 additions & 4 deletions doorstop/core/test/test_importer.py
Expand Up @@ -94,13 +94,14 @@ def test_file_csv_modified(self, mock_itemize):
expected_data = [['REQ0555', '1.2.3', 'Hello, world!\n', '',
'SYS001,\nSYS002', True, False, False, ''],
['REQ003', '1.4', 'Hello, world!\n', 'REF''123',
'REQ001', False, False, True, "''"],
'REQ001', False, False, True,
'Some "quoted" text \'here\'.'],
['REQ004', '1.6', 'Hello, world!\n', '',
'', False, True, True, 'DOORSTOP RULES!!'],
'', False, True, True, ''],
['REQ002', '2.1', 'Hello, world!\n', '',
'', True, False, True, "Hey, I've got some text. The \"Back\" button should be 'bold'. I said \"failure's\"."],
'', True, False, True, ''],
['REQ2-001', '2.1', 'Hello, world!\n', '',
'REQ001', True, False, True, 'Is alive?\n']]
'REQ001', True, False, True, '']]
self.assertEqual(expected_data, data)
self.assertIs(mock_document, document)

Expand Down

0 comments on commit 8c197fd

Please sign in to comment.