Exemplo n.º 1
0
 def test_cache_maximum_size_1(self):
     cache = Cache(max_cache_size=2)
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     # override is True by default, but this makes it explicit that it is testing for this (default) situation
     cache.update(key='c', data=self.data_dict['c'], override=True)
     self.assertFalse('a' in cache)
Exemplo n.º 2
0
    def __init__(self,
                 antibody_objects=None,
                 path=None,
                 verbose=True,
                 show_progressbar=True,
                 n_threads=10):
        super().__init__(antibody_objects=antibody_objects)
        if antibody_objects:
            self.load()
        else:
            self.__init__(antibody_objects=ChainCollection.load_from_file(
                path=path,
                verbose=verbose,
                show_progressbar=show_progressbar,
                n_threads=n_threads))

        self._cache = Cache(max_cache_size=5)
Exemplo n.º 3
0
 def test_cache_maximum_size_exception(self):
     cache = Cache(max_cache_size=2)
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     self.assertRaises(ValueError, cache.update, 'c', self.data_dict['c'],
                       False)
Exemplo n.º 4
0
 def test_cache_maximum_size_2(self):
     cache = Cache(max_cache_size=2)
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     cache.update(key='c', data=self.data_dict['c'], override=True)
     self.assertEqual(len(cache), 2)
Exemplo n.º 5
0
 def test_cache_empty(self):
     cache = Cache()
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     cache.empty_cache()
     self.assertEqual(len(cache), 0)
Exemplo n.º 6
0
 def test_cache_remove_key(self):
     cache = Cache()
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     cache.remove('a')
     self.assertFalse('a' in cache)
Exemplo n.º 7
0
 def test_contains(self):
     cache = Cache()
     cache.update(key='a', data=self.data_dict['a'])
     self.assertTrue('a' in cache)
Exemplo n.º 8
0
 def test_cache_update_2(self):
     # check if cache works when adding a second item
     cache = Cache()
     cache.update(key='a', data=self.data_dict['a'])
     cache.update(key='b', data=self.data_dict['b'])
     self.assertEqual(cache['b'], self.data_dict['b'])
Exemplo n.º 9
0
 def test_cache_update_1(self):
     cache = Cache()
     cache.update(key='a', data=self.data_dict['a'])
     self.assertEqual(cache['a'], self.data_dict['a'])
Exemplo n.º 10
0
 def test_cache_instantiation(self):
     cache = Cache()
     self.assertIsInstance(cache, Cache)