def test_tuple_iterator(self): data_map = DataMap(self.new_style_map) data_map.iterator = DataMap.TupleIterator tuples = [item for item in data_map] self.assertEqual(len(tuples), 4) self.assertTrue(all(isinstance(item, tuple) for item in tuples)) self.assertTrue(all(len(item) == 2 for item in tuples)) self.assertEqual(tuples[0], ('locus001', 'L12345_SB101.MS'))
def test_tuple_iterator(self): data_map = DataMap(self.new_style_map) data_map.iterator = DataMap.TupleIterator tuples = [item for item in data_map] self.assertEqual(len(tuples), 4) self.assertTrue(all(isinstance(item, tuple) for item in tuples)) self.assertTrue(all(len(item) == 2 for item in tuples)) self.assertEqual(tuples[0], ('locus001', 'L12345_SB101.MS'))
def test_skip_iterator(self): data_map = DataMap(self.new_style_map) data_map.iterator = DataMap.SkipIterator unskipped = [item for item in data_map] self.assertEqual(len(unskipped), 2) self.assertTrue(all(isinstance(item, DataProduct) for item in unskipped)) self.assertEqual(unskipped[0].host, 'locus002') self.assertEqual(unskipped[0].file, 'L12345_SB102.MS')
def test_skip_iterator(self): data_map = DataMap(self.new_style_map) data_map.iterator = DataMap.SkipIterator unskipped = [item for item in data_map] self.assertEqual(len(unskipped), 2) self.assertTrue( all(isinstance(item, DataProduct) for item in unskipped)) self.assertEqual(unskipped[0].host, 'locus002') self.assertEqual(unskipped[0].file, 'L12345_SB102.MS')
def test_append_item_non_skip(self): data_map = DataMap(self.new_style_map) data_map.append(("host", "file", False)) data_map.iterator = DataMap.TupleIterator tuples = [item for item in data_map] self.assertEqual(len(tuples), 5) self.assertTrue(all(isinstance(item, tuple) for item in tuples)) self.assertTrue(all(len(item) == 2 for item in tuples)) self.assertEqual(tuples[-1], ('host', 'file'))
def test_append_item_non_skip(self): data_map = DataMap(self.new_style_map) data_map.append(("host","file", False)) data_map.iterator = DataMap.TupleIterator tuples = [item for item in data_map] self.assertEqual(len(tuples), 5) self.assertTrue(all(isinstance(item, tuple) for item in tuples)) self.assertTrue(all(len(item) == 2 for item in tuples)) self.assertEqual(tuples[-1], ('host', 'file'))
def test_append_item_skip(self): data_map = DataMap(self.new_style_map) data_map.append(("host", "file", True)) data_map.iterator = DataMap.SkipIterator dataProducts = [item for item in data_map] # default contains 2 nonskipped items self.assertEqual(len(dataProducts), 2) self.assertTrue( all(isinstance(item, DataProduct) for item in dataProducts)) # The map already contains 2 skipped items, the final item is tested # here self.assertEqual(dataProducts[-1].host, 'locus004') self.assertEqual(dataProducts[-1].file, 'L12345_SB104.MS')
def test_append_item_skip(self): data_map = DataMap(self.new_style_map) data_map.append(("host","file", True)) data_map.iterator = DataMap.SkipIterator dataProducts = [item for item in data_map] # default contains 2 nonskipped items self.assertEqual(len(dataProducts), 2) self.assertTrue(all(isinstance(item, DataProduct) for item in dataProducts)) # The map already contains 2 skipped items, the final item is tested # here self.assertEqual(dataProducts[-1].host, 'locus004') self.assertEqual(dataProducts[-1].file, 'L12345_SB104.MS')