def test_read_csv_gse_as_key_invalid_format1(self, L): m = mock.mock_open(read_data=os.linesep.join( ['GSE1,GSM1', 'GSE1,H**o sapiens,GSM2', 'GSE2,H**o sapiens,GSM3'])) m.return_value.__iter__ = lambda self: StringIO.StringIO(self.read()) m.return_value.__next__ = lambda self: self.readline() with mock.patch('rsempipeline.parsers.isamp_parser.open', m): res = isamp_parser.read_csv_gse_as_key('infile.csv') self.assertEqual(res, {'GSE1': ['GSM2'], 'GSE2': ['GSM3']}) L.check(('rsempipeline.parsers.isamp_parser', 'ERROR', "Ignored invalid row (1): ['GSE1', 'GSM1']"))
def test_read_csv_gse_as_key_invalid_format3(self, L): m = mock.mock_open(read_data=os.linesep.join( [ 'GSE1,H**o sapiens,GSM', ])) m.return_value.__iter__ = lambda self: StringIO.StringIO(self.read()) m.return_value.__next__ = lambda self: self.readline() with mock.patch('rsempipeline.parsers.isamp_parser.open', m): res = isamp_parser.read_csv_gse_as_key('infile.csv') self.assertEqual(res, {}) L.check(('rsempipeline.parsers.isamp_parser', 'ERROR', "Ignored invalid row (1): ['GSE1', 'H**o sapiens', 'GSM']"))
def test_read_csv_gse_as_key(self): m = mock.mock_open(read_data=os.linesep.join([ 'GSE1,H**o sapiens,GSM1', 'GSE1,H**o sapiens,GSM2', 'GSE2,H**o sapiens,GSM3' ])) # use StringIO.StringIO because inf will be read by csv.reader, it must # return an iternator, refer to test_soft_parser.test_parse for the # other scenario m.return_value.__iter__ = lambda self: StringIO.StringIO(self.read()) m.return_value.__next__ = lambda self: self.readline() with mock.patch('rsempipeline.parsers.isamp_parser.open', m): res = isamp_parser.read_csv_gse_as_key('infile.csv') self.assertEqual(res, {'GSE1': ['GSM1', 'GSM2'], 'GSE2': ['GSM3']})
def test_read_csv_gse_as_key(self): m = mock.mock_open(read_data=os.linesep.join( [ 'GSE1,H**o sapiens,GSM1', 'GSE1,H**o sapiens,GSM2', 'GSE2,H**o sapiens,GSM3' ])) # use StringIO.StringIO because inf will be read by csv.reader, it must # return an iternator, refer to test_soft_parser.test_parse for the # other scenario m.return_value.__iter__ = lambda self: StringIO.StringIO(self.read()) m.return_value.__next__ = lambda self: self.readline() with mock.patch('rsempipeline.parsers.isamp_parser.open', m): res = isamp_parser.read_csv_gse_as_key('infile.csv') self.assertEqual(res, { 'GSE1': ['GSM1', 'GSM2'], 'GSE2': ['GSM3'] })