예제 #1
0
 def test_local_csv_header(self):
     mOpen = mock_open(read_data='htid\nrow1\nrow2\n')
     mOpen.return_value.__iter__ = lambda self: self
     mOpen.return_value.__next__ = lambda self: next(iter(self.readline, ''))
     with patch('service.open', mOpen, create=True) as mCSV:
         rows = loadLocalCSV('localFile')
         mCSV.assert_called_once_with('localFile', newline='')
         self.assertEqual(rows[0][0], 'row1')
예제 #2
0
 def test_local_csv_success(self):
     mOpen = mock_open(read_data='id1,r1.2,pd\nid2,r2.2,pd\n')
     mOpen.return_value.__iter__ = lambda s: s
     mOpen.return_value.__next__ = lambda s: next(iter(s.readline, ''))
     with patch('service.open', mOpen, create=True) as mCSV:
         rows = loadLocalCSV('localFile', 0, 3)
         mCSV.assert_called_once_with('localFile', newline='')
         self.assertEqual(rows[0][0], 'id1')
예제 #3
0
 def test_local_csv_missing(self):
     with self.assertRaises(ProcessingError):
         loadLocalCSV('localFile')