Example #1
0
def test_mutable():
    sm = StoreMixin()
    sm.open_storage(MemoryStoragePlugin(None), 'ns')
    sm['toto'] = [1, 3]

    with sm.mutable('toto') as titi:
        titi[1] = 5

    assert sm['toto'] == [1, 5]
Example #2
0
def test_mutable():
    sm = StoreMixin()
    sm.open_storage(MemoryStoragePlugin(None), "ns")
    sm["toto"] = [1, 3]

    with sm.mutable("toto") as titi:
        titi[1] = 5

    assert sm["toto"] == [1, 5]
Example #3
0
    def test_storage(self):
        key = b'test' if PY2 else 'test'
        config = sys.modules['errbot.config-template']
        bot_config_defaults(config)

        spm = SpecificPluginManager(config, 'storage', StoragePluginBase, CORE_STORAGE, None)
        storage_plugin = spm.get_plugin_by_name('Memory')

        persistent_object = StoreMixin()
        persistent_object.open_storage(storage_plugin, 'test')
        persistent_object[key] = 'à value'
        self.assertEquals(persistent_object[key], 'à value')
        self.assertIn(key, persistent_object)
        del persistent_object[key]
        self.assertNotIn(key, persistent_object)
        self.assertEquals(len(persistent_object), 0)
Example #4
0
    def test_storage(self):
        key = b'test' if PY2 else 'test'
        config = sys.modules['errbot.config-template']
        bot_config_defaults(config)

        spm = SpecificPluginManager(config, 'storage', StoragePluginBase,
                                    CORE_STORAGE, None)
        storage_plugin = spm.get_plugin_by_name('Memory')

        persistent_object = StoreMixin()
        persistent_object.open_storage(storage_plugin, 'test')
        persistent_object[key] = 'à value'
        self.assertEquals(persistent_object[key], 'à value')
        self.assertIn(key, persistent_object)
        del persistent_object[key]
        self.assertNotIn(key, persistent_object)
        self.assertEquals(len(persistent_object), 0)
Example #5
0
def test_storage():
    key = 'test'

    __import__('errbot.config-template')
    config = ShallowConfig()
    config.__dict__.update(sys.modules['errbot.config-template'].__dict__)
    bot_config_defaults(config)

    spm = BackendPluginManager(config, 'errbot.storage', 'Memory', StoragePluginBase, CORE_STORAGE)
    storage_plugin = spm.load_plugin()

    persistent_object = StoreMixin()
    persistent_object.open_storage(storage_plugin, 'test')
    persistent_object[key] = 'à value'
    assert persistent_object[key] == 'à value'
    assert key in persistent_object
    del persistent_object[key]
    assert key not in persistent_object
    assert len(persistent_object) == 0
Example #6
0
def test_storage():
    key = b'test' if PY2 else 'test'

    __import__('errbot.config-template')
    config = ShallowConfig()
    config.__dict__.update(sys.modules['errbot.config-template'].__dict__)
    bot_config_defaults(config)

    spm = SpecificPluginManager(config, 'storage', StoragePluginBase, CORE_STORAGE, None)
    storage_plugin = spm.get_plugin_by_name('Memory')

    persistent_object = StoreMixin()
    persistent_object.open_storage(storage_plugin, 'test')
    persistent_object[key] = 'à value'
    assert persistent_object[key] == 'à value'
    assert key in persistent_object
    del persistent_object[key]
    assert key not in persistent_object
    assert len(persistent_object) == 0
Example #7
0
def test_storage():
    key = 'test'

    __import__('errbot.config-template')
    config = ShallowConfig()
    config.__dict__.update(sys.modules['errbot.config-template'].__dict__)
    bot_config_defaults(config)

    spm = SpecificPluginManager(config, 'storage', StoragePluginBase,
                                CORE_STORAGE, None)
    storage_plugin = spm.get_plugin_by_name('Memory')

    persistent_object = StoreMixin()
    persistent_object.open_storage(storage_plugin, 'test')
    persistent_object[key] = 'à value'
    assert persistent_object[key] == 'à value'
    assert key in persistent_object
    del persistent_object[key]
    assert key not in persistent_object
    assert len(persistent_object) == 0
Example #8
0
def test_storage():
    key = "test"

    __import__("errbot.config-template")
    config = ShallowConfig()
    config.__dict__.update(sys.modules["errbot.config-template"].__dict__)
    bot_config_defaults(config)

    spm = BackendPluginManager(config, "errbot.storage", "Memory",
                               StoragePluginBase, CORE_STORAGE)
    storage_plugin = spm.load_plugin()

    persistent_object = StoreMixin()
    persistent_object.open_storage(storage_plugin, "test")
    persistent_object[key] = "à value"
    assert persistent_object[key] == "à value"
    assert key in persistent_object
    del persistent_object[key]
    assert key not in persistent_object
    assert len(persistent_object) == 0
Example #9
0
 def storage_action(namespace, fn):
     # Used to defer imports until it is really necessary during the loading time.
     from errbot.bootstrap import get_storage_plugin
     from errbot.storage import StoreMixin
     try:
         with StoreMixin() as sdm:
             sdm.open_storage(get_storage_plugin(config), namespace)
             fn(sdm)
         return 0
     except Exception as e:
         print(str(e), file=sys.stderr)
         return -3
Example #10
0
def test_simple_store_retreive():
    sm = StoreMixin()
    sm.open_storage(MemoryStoragePlugin(None), 'ns')
    sm['toto'] = 'titui'
    assert sm['toto'] == 'titui'
Example #11
0
def test_simple_store_retreive():
    sm = StoreMixin()
    sm.open_storage(MemoryStoragePlugin(None), "ns")
    sm["toto"] = "titui"
    assert sm["toto"] == "titui"