Ejemplo n.º 1
0
    def test_process_line(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FilePropertyStore(engine)

        self.assertFalse(store._process_line("", {}))
        self.assertFalse(store._process_line("#name:Y-Bot", {}))
        self.assertTrue(store._process_line("name:Y-Bot", {}))
Ejemplo n.º 2
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FilePropertyStore(engine)

        self.assertEquals('/tmp/properties/properties.txt',
                          store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Ejemplo n.º 3
0
    def test_load_properties(self):
        config = FileStorageConfiguration()
        config._properties_storage = FileStoreConfiguration(file=os.path.dirname(__file__) + os.sep + "data" + os.sep + "lookups" + os.sep + "text" + os.sep + "properties.txt", format="text", encoding="utf-8", delete_on_start=False)
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FilePropertyStore(engine)

        collection = PropertiesCollection()
        store.load(collection)

        self.assertTrue(collection.has_key("name"))
        self.assertTrue("Y-Bot", collection.value("name"))
        self.assertTrue(collection.has_key("firstname"))
        self.assertTrue("Y", collection.value("firstname"))
        self.assertTrue(collection.has_key("middlename"))
        self.assertTrue("AIML", collection.value("middlename"))
Ejemplo n.º 4
0
    def test_empty_properties(self):
        config = FileStorageConfiguration()
        config.properties_storage._dirs = [self._tmpfile]
        config.properties_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FilePropertyStore(engine)

        if os.path.exists(self._tmpdir) is False:
            os.mkdir(self._tmpdir)
        self.assertTrue(os.path.exists(self._tmpdir))

        self.assert_empty_properties(store)
Ejemplo n.º 5
0
    def test_empty_properties(self):
        config = FileStorageConfiguration()
        tmpdir = os.path.dirname(__file__) + os.sep + "properties"
        tmpfile = tmpdir + os.sep + "properties.txt"
        config.properties_storage._dirs = [tmpfile]
        config.properties_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FilePropertyStore(engine)

        if os.path.exists(tmpdir) is False:
            os.mkdir(tmpdir)
        self.assertTrue(os.path.exists(tmpdir))

        self.assert_empty_properties(store)

        shutil.rmtree(tmpdir)
        self.assertFalse(os.path.exists(tmpdir))
Ejemplo n.º 6
0
 def property_store(self):
     return FilePropertyStore(self)
Ejemplo n.º 7
0
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FilePropertyStore(engine)
     self.assertEqual(store.storage_engine, engine)