def test_get_gsms_transferred(self, mock_exists): mock_exists.return_value = True # known issue, mock_open doesn't implement iteration, # http://stackoverflow.com/questions/24779893/customizing-unittest-mock-mock-open-for-iteration # cannot successfully implement what is suggested in this thread, but # my such hack works m = mock.mock_open() m.return_value.__iter__.return_value = [ '# 15-07-17 09:04:38', 'rsem_output/GSE34736/homo_sapiens/GSM854343', 'rsem_output/GSE34736/homo_sapiens/GSM854344' ] with mock.patch('rsempipeline.core.rp_transfer.open', m): self.assertEqual(RP_T.get_gsms_transferred('transferred_GSMs.txt'), ['rsem_output/GSE34736/homo_sapiens/GSM854343', 'rsem_output/GSE34736/homo_sapiens/GSM854344'])
def test_get_gsms_transferred(self, mock_exists): mock_exists.return_value = True # known issue, mock_open doesn't implement iteration, # http://stackoverflow.com/questions/24779893/customizing-unittest-mock-mock-open-for-iteration # cannot successfully implement what is suggested in this thread, but # my such hack works m = mock.mock_open() m.return_value.__iter__.return_value = [ '# 15-07-17 09:04:38', 'rsem_output/GSE34736/homo_sapiens/GSM854343', 'rsem_output/GSE34736/homo_sapiens/GSM854344' ] with mock.patch('rsempipeline.core.rp_transfer.open', m): self.assertEqual(RP_T.get_gsms_transferred('transferred_GSMs.txt'), [ 'rsem_output/GSE34736/homo_sapiens/GSM854343', 'rsem_output/GSE34736/homo_sapiens/GSM854344' ])
def test_get_gsms_transferred_record_file_not_exist(self): self.assertEqual( RP_T.get_gsms_transferred('nonexistent_transferred_GSMs.txt'), [])
def test_get_gsms_transferred_record_file_not_exist(self): self.assertEqual(RP_T.get_gsms_transferred('nonexistent_transferred_GSMs.txt'), [])