Exemplo n.º 1
0
 def test_from_config_none_type(self):
     # When config map given, but plugin type set to null/None
     config = {'cache_element': {
         'some_type': {'param': None},
         'type': None,
     }}
     s = MemoryKeyValueStore.from_config(config)
     self.assertIsNone(s._cache_element)
     self.assertEqual(s._table, {})
Exemplo n.º 2
0
    def test_from_config_with_cache_element(self):
        # Pickled dictionary with a known entry
        expected_table = {'some_key': 'some_value'}
        empty_dict_pickle = six.b("(dp1\nS'some_key'\np2\nS'some_value'\np3\ns.")

        # Test construction with memory data element.
        config = {'cache_element': {
            'DataMemoryElement': {
                'bytes': empty_dict_pickle,
            },
            'type': 'DataMemoryElement'
        }}
        s = MemoryKeyValueStore.from_config(config)
        self.assertIsInstance(s._cache_element, DataMemoryElement)
        self.assertEqual(s._table, expected_table)
Exemplo n.º 3
0
    def test_from_config_with_cache_element(self):
        # Pickled dictionary with a known entry
        expected_table = {'some_key': 'some_value'}
        empty_dict_pickle_str = \
            pickle.dumps(expected_table).decode(BYTES_CONFIG_ENCODING)

        # Test construction with memory data element.
        config = {
            'cache_element': {
                'DataMemoryElement': {
                    'bytes': empty_dict_pickle_str,
                },
                'type': 'DataMemoryElement'
            }
        }
        s = MemoryKeyValueStore.from_config(config)
        self.assertIsInstance(s._cache_element, DataMemoryElement)
        self.assertEqual(s._table, expected_table)
Exemplo n.º 4
0
 def test_from_config_none_value(self):
     # When cache_element value is None
     expected_config = {'cache_element': None}
     s = MemoryKeyValueStore.from_config(expected_config)
     nose.tools.assert_is_none(s._cache_element)
     nose.tools.assert_equal(s._table, {})
Exemplo n.º 5
0
 def test_from_config_empty_config(self):
     # should resort to default parameters
     s = MemoryKeyValueStore.from_config({})
     nose.tools.assert_is_none(s._cache_element)
     nose.tools.assert_equal(s._table, {})
 def test_from_config_empty_config(self):
     # should resort to default parameters
     s = MemoryKeyValueStore.from_config({})
     self.assertIsNone(s._cache_element)
     self.assertEqual(s._table, {})
Exemplo n.º 7
0
 def test_from_config_none_value(self):
     # When cache_element value is None
     expected_config = {'cache_element': None}
     s = MemoryKeyValueStore.from_config(expected_config)
     self.assertIsNone(s._cache_element)
     self.assertEqual(s._table, {})
Exemplo n.º 8
0
 def test_from_config_empty_config(self):
     # should resort to default parameters
     s = MemoryKeyValueStore.from_config({})
     self.assertIsNone(s._cache_element)
     self.assertEqual(s._table, {})