Ejemplo n.º 1
0
 def test_write_non_dict_data(self):
     self.kvs = MongoKeyValueStore('xml_data', self.parent, self.children,
                                   self.metadata)
     self._check_write(KeyValueStore.Key(Scope.content, None, None, 'data'),
                       'new_data')
Ejemplo n.º 2
0
 def test_read_invalid_scope(self):
     for scope in (Scope.preferences, Scope.user_info, Scope.user_state):
         key = KeyValueStore.Key(scope, None, None, 'foo')
         with assert_raises(InvalidScopeError):
             self.kvs.get(key)
         assert_false(self.kvs.has(key))
Ejemplo n.º 3
0
 def test_read_non_dict_data(self):
     self.kvs = MongoKeyValueStore('xml_data', self.parent, self.children,
                                   self.metadata)
     assert_equals(
         'xml_data',
         self.kvs.get(KeyValueStore.Key(Scope.content, None, None, 'data')))
 def test_write_invalid_scope(self):
     for scope in (Scope.preferences, Scope.user_info, Scope.user_state):
         with pytest.raises(InvalidScopeError):
             self.kvs.set(KeyValueStore.Key(scope, None, None, 'foo'),
                          'new_value')
 def test_delete_invalid_scope(self):
     for scope in (Scope.preferences, Scope.user_info, Scope.user_state,
                   Scope.parent):
         with pytest.raises(InvalidScopeError):
             self.kvs.delete(KeyValueStore.Key(scope, None, None, 'foo'))
Ejemplo n.º 6
0
 def test_read_non_dict_data(self):
     self.kvs._data = 'xml_data'
     assert_equals(
         'xml_data',
         self.kvs.get(KeyValueStore.Key(Scope.content, None, None, 'data')))
Ejemplo n.º 7
0
 def test_write_non_dict_data(self):
     self.kvs._data = 'xml_data'
     self._check_write(KeyValueStore.Key(Scope.content, None, None, 'data'),
                       'new_data')
Ejemplo n.º 8
0
 def get_key_value(scope, user_id, block_scope_id, field_name):
     """Gets the value, from `key_store`, of a Key with the given values."""
     new_key = KeyValueStore.Key(scope, user_id, block_scope_id, field_name)
     return key_store.db_dict[new_key]
Ejemplo n.º 9
0
 def test_delete(self):
     yield (self._check_delete_key_error, KeyValueStore.Key(Scope.content, None, None, 'foo'))
     yield (self._check_delete_default, KeyValueStore.Key(Scope.children, None, None, 'children'), [])
     yield (self._check_delete_key_error, KeyValueStore.Key(Scope.settings, None, None, 'meta'))
Ejemplo n.º 10
0
 def test_write(self):
     yield (self._check_write, KeyValueStore.Key(Scope.content, None, None, 'foo'), 'new_data')
     yield (self._check_write, KeyValueStore.Key(Scope.children, None, None, 'children'), [])
     yield (self._check_write, KeyValueStore.Key(Scope.children, None, None, 'parent'), None)
     yield (self._check_write, KeyValueStore.Key(Scope.settings, None, None, 'meta'), 'new_settings')
Ejemplo n.º 11
0
 def test_read(self):
     assert_equals(self.data['foo'], self.kvs.get(KeyValueStore.Key(Scope.content, None, None, 'foo')))
     assert_equals(self.parent, self.kvs.get(KeyValueStore.Key(Scope.parent, None, None, 'parent')))
     assert_equals(self.children, self.kvs.get(KeyValueStore.Key(Scope.children, None, None, 'children')))
     assert_equals(self.metadata['meta'], self.kvs.get(KeyValueStore.Key(Scope.settings, None, None, 'meta')))
Ejemplo n.º 12
0
 def setUp(self):
     self.kvs = WorkbenchDjangoKeyValueStore()
     self.key = KeyValueStore.Key(scope=Scope.content,
                                  user_id="rusty",
                                  block_scope_id="my_scenario.my_block.d0",
                                  field_name="age")