def test_from_config_with_cache(self) -> None: c = LinearHashIndex.get_default_config() c['cache_element'][ 'type'] = 'smqtk_dataprovider.impls.data_element.memory.DataMemoryElement' i = LinearHashIndex.from_config(c) self.assertIsInstance(i.cache_element, DataMemoryElement) self.assertEqual(i.index, set())
def test_get_config(self) -> None: i = LinearHashIndex() # Without cache element expected_c = LinearHashIndex.get_default_config() self.assertEqual(i.get_config(), expected_c) # With cache element i.cache_element = DataMemoryElement() expected_c['cache_element'][ 'type'] = 'smqtk_dataprovider.impls.data_element.memory.DataMemoryElement' self.assertEqual(i.get_config(), expected_c)
def test_from_config_no_cache(self) -> None: # Default config is valid and specifies no cache. c = LinearHashIndex.get_default_config() i = LinearHashIndex.from_config(c) self.assertIsNone(i.cache_element) self.assertEqual(i.index, set())
def test_default_config(self) -> None: c = LinearHashIndex.get_default_config() self.assertEqual(len(c), 1) self.assertIsNone(c['cache_element']['type'])