def test_file_csv_modified(self, mock_itemize): """Verify a CSV file (with modifications) can be imported.""" path = os.path.join(FILES, 'exported-modified.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = [ 'id', 'level', 'text', 'ref', 'links', 'active', 'derived', 'normative', 'additional', ] self.assertEqual(expected_header, header) expected_data = [ [ 'REQ0555', '1.2.3', 'Hello, world!\n', '', 'SYS001,\nSYS002', True, False, False, '', ], # pylint: disable=implicit-str-concat-in-sequence # 'REF''123' is intentional to avoid matching the reference in this test file [ 'REQ003', '1.4', 'Hello, world!\n', 'REF' '123', 'REQ001', False, False, True, 'Some "quoted" text \'here\'.', ], ['REQ004', '1.6', 'Hello, world!\n', '', '', False, True, True, ''], ['REQ002', '2.1', 'Hello, world!\n', '', '', True, False, True, ''], ['REQ2-001', '2.1', 'Hello, world!\n', '', 'REQ001', True, False, True, ''], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)
def test_file_csv(self, mock_itemize): """Verify a CSV file can be imported.""" # pylint: disable=C0301 path = os.path.join(FILES, 'exported.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # pylint: disable=W0212 # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = ['uid', 'level', 'text', 'ref', 'links', 'active', 'derived', 'normative', 'reviewed'] self.assertEqual(expected_header, header) expected_data = [ ['REQ001', '1.2.3', 'The foo shall bar all night long!', '', 'SYS001\nSYS002:abc123', True, False, True, ''], ['REQ003', '1.4', 'Unicode: -40° ±1%', 'REF''123', 'REQ001', True, False, True, ''], ['REQ004', '1.6', 'Hello, world!', '', '', True, False, True, ''], ['REQ002', '2.1', 'Hello, world!', '', '', True, False, True, 'b5fbcc355112791bbcd2ea881c7c5f81'], ['REQ2-001', '2.1', 'Hello, world!', '', 'REQ001', True, False, True, ''], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)
def test_file_csv_modified(self, mock_itemize): """Verify a CSV file (with modifications) can be imported.""" # pylint: disable=C0301 path = os.path.join(FILES, 'exported-modified.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # pylint: disable=W0212 # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = ['id', 'level', 'text', 'ref', 'links', 'active', 'derived', 'normative', 'additional'] self.assertEqual(expected_header, header) 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, 'Some "quoted" text \'here\'.'], ['REQ004', '1.6', 'Hello, world!\n', '', '', False, True, True, ''], ['REQ002', '2.1', 'Hello, world!\n', '', '', True, False, True, ''], ['REQ2-001', '2.1', 'Hello, world!\n', '', 'REQ001', True, False, True, ''], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)
def test_file_csv(self, mock_itemize): """Verify a CSV file can be imported.""" # pylint: disable=C0301 path = os.path.join(FILES, 'exported.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # pylint: disable=W0212 # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = ['uid', 'level', 'text', 'ref', 'links', 'active', 'derived', 'normative', 'reviewed'] self.assertEqual(expected_header, header) expected_data = [ ['REQ001', '1.2.3', 'The foo shall bar all night long!\n', '', 'SYS001\nSYS002:abc123', True, False, True, ''], ['REQ003', '1.4', 'Unicode: -40° ±1%\n', 'REF''123', 'REQ001', True, False, True, ''], ['REQ004', '1.6', 'Hello, world!\n', '', '', True, False, True, ''], ['REQ002', '2.1', 'Hello, world!\n', '', '', True, False, True, 'b5fbcc355112791bbcd2ea881c7c5f81'], ['REQ2-001', '2.1', 'Hello, world!\n', '', 'REQ001', True, False, True, ''], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)
def test_file_csv(self, mock_itemize): """Verify a CSV file can be imported.""" path = os.path.join(FILES, 'exported.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = [ 'uid', 'level', 'text', 'ref', 'references', 'links', 'active', 'derived', 'header', 'normative', 'reviewed', ] self.assertEqual(expected_header, header) expected_data = [ [ 'REQ001', '1.2.3', LOREM_IPSUM, '', '', 'SYS001\nSYS002:abc123', True, False, '', True, '', ], # pylint: disable=implicit-str-concat-in-sequence # 'REF''123' is intentional to avoid matching the reference in this test file [ 'REQ003', '1.4', 'Unicode: -40° ±1%', 'REF' '123', '', 'REQ001', True, False, '', True, '', ], [ 'REQ006', '1.5', 'Hello, world!', '', 'type:file,path:external/text.txt,keyword:REF123\ntype:file,path:external/text2.txt', 'REQ001:35ed54323e3054c33ae5545fffdbbbf5', True, False, '', True, 'c442316131ca0225595ae257f3b4583d', ], [ 'REQ004', '1.6', 'Hello, world!', '', '', '', True, False, '', True, '' ], [ 'REQ002', '2.1', 'Hello, world!\n\n' + PLANTUML_TXT, '', '', '', True, False, 'Plantuml', True, '1PvBLmy0xmdK_zLKrLu1au0wlIw_zsD6A8Oc5F4zWxU=', ], [ 'REQ2-001', '2.1', 'Hello, world!\n\n' + LATEX_MATH, '', '', 'REQ001', True, False, '', True, '', ], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)
def test_file_csv(self, mock_itemize): """Verify a CSV file can be imported.""" path = os.path.join(FILES, 'exported.csv') mock_document = Mock() # Act importer._file_csv(path, mock_document) # Assert args, kwargs = mock_itemize.call_args logging.debug("args: {}".format(args)) logging.debug("kwargs: {}".format(kwargs)) header, data, document = args expected_header = [ 'uid', 'level', 'text', 'ref', 'links', 'active', 'derived', 'header', 'normative', 'reviewed', ] self.assertEqual(expected_header, header) expected_data = [ [ 'REQ001', '1.2.3', LOREM_IPSUM, '', 'SYS001\nSYS002:abc123', True, False, '', True, '', ], # pylint: disable=implicit-str-concat-in-sequence # 'REF''123' is intentional to avoid matching the reference in this test file [ 'REQ003', '1.4', 'Unicode: -40° ±1%', 'REF' '123', 'REQ001', True, False, '', True, '', ], ['REQ004', '1.6', 'Hello, world!', '', '', True, False, '', True, ''], [ 'REQ002', '2.1', 'Hello, world!\n\n' + PLANTUML_TXT, '', '', True, False, 'Plantuml', True, '50ae164a198e612dee696cc80942dc29', ], [ 'REQ2-001', '2.1', 'Hello, world!\n\n' + LATEX_MATH, '', 'REQ001', True, False, '', True, '', ], ] self.assertEqual(expected_data, data) self.assertIs(mock_document, document)