def test_add_read(self): fh = MockBamFileHandle() b = BamCache(fh) r = MockRead('name') b.add_read(r) self.assertEqual(1, len(b.cache.values())) self.assertEqual(set([r]), b.cache['name'])
def test_add_invalid_read(self, log_patcher): bad_read = mock.Mock( is_unmapped=False, reference_start=0, reference_end=0, query_name='BAD_READ' ) cache = BamCache(MockBamFileHandle()) cache.add_read(bad_read) self.assertEqual(0, len(cache.cache)) log_patcher.assert_called_with('ignoring invalid read', 'BAD_READ', level=logging.DEBUG)
def test_add_invalid_read(self, log_patcher): bad_read = mock.Mock( is_unmapped=False, reference_start=0, reference_end=0, query_name='BAD_READ' ) cache = BamCache(MockBamFileHandle()) cache.add_read(bad_read) assert len(cache.cache) == 0 log_patcher.method_calls[0].assert_called_with('ignoring invalid read: BAD_READ')
def test_add_read(self): fh = MockBamFileHandle() b = BamCache(fh) r = mock.MagicMock(query_name='name', query_sequence='') b.add_read(r) self.assertEqual(1, len(b.cache.values())) b.add_read(r) self.assertEqual(1, len(b.cache.values())) r.reference_start = 0 b.add_read(r) self.assertEqual(1, len(b.cache.values()))