# Path: nive_cms/tests/db_app.py
# def app_db(confs=None):
# def app_nodb():
# def emptypool(app):
# def createpool(path,app):
# def root(a):
# def create_page(c, user):
# def create_box(c, user):
# def create_column(c, user):
# def create_file(c, user):
# def create_image(c, user):
# def create_media(c, user):
# def create_note(c, user):
# def create_text(c, user):
# def create_spacer(c, user):
# def create_link(c, user):
# def create_menublock(c, user):
# def create_code(c, user):
# def create_news(c, user):
# 
# Path: nive_cms/tests/__local.py
# WIN = sys.platform.startswith("win")
#     ROOT = "c:\\Temp\\nive_cms\\"
#     ROOT = "/var/tmp/nive_cms/"
# DB_CONF = DatabaseConf(
#     dbName = ROOT+"cms.db",
#     fileRoot = ROOT,
#     context = "Sqlite3"
# )
# MYSQL_CONF = DatabaseConf(
#     context = "MySql",
#     dbName = "ut_nive_cms",
#     host = "localhost",
#     user = "root",
#     password = "",
#     port = "",
#     fileRoot = ROOT
# )
# POSTGRES_CONF = DatabaseConf(
#     context = "PostgreSql",
#     dbName = "ut_nive_cms",
#     host = "localhost",
#     user = "postgres",
#     password = "postgres",
#     port = "",
#     fileRoot = ROOT
# )
# ENABLE_SQLITE_TESTS = True
# ENABLE_MYSQL_TESTS = False
# ENABLE_POSTGRES_TESTS = False
#     class SqliteTestCase(unittest.TestCase):
#     class SqliteTestCase(object):
#     class MySqlTestCase(unittest.TestCase):
#     class MySqlTestCase(object):
#     class PostgreSqlTestCase(unittest.TestCase):
#     class PostgreSqlTestCase(object):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):


import unittest
from nive.definitions import *
from nive_cms.extensions.path import *
from nive.security import User
from nive_cms.tests import db_app
from nive.utils import language_data
from nive_cms.tests import __local
        self.assert_(fn ==    u"this_is_a_looooooooooooooooooooooooooooooooooooooo", fn)
        
        fn = p.EscapeFilename(u"This Is a loooooooooooooooooooooooooooooooong Filename")
        self.assert_(fn ==    u"this_is_a_loooooooooooooooooooooooooooooooong", fn)
        
        fn = p.EscapeFilename(u"This Is ä Filename")
        self.assert_(fn ==    u"this_is_a_filename", fn)
        
        
    def test_special_chars(self):
        p = AlternatePath()
        p.app = self.app
        
        for lang in language_data.languages:
            conf = language_data.GetConf(lang)
            if not conf.get("special_chars"):
                continue
            
            fn = p.EscapeFilename(u"test " + conf.get("special_chars"))
            self.assert_(fn.startswith(u"test"), fn)
            
        
        
class tWf(__local.DefaultTestCase):

    def setUp(self):
        self._loadApp()
        user = self.user = User(u"test")
        user.groups.append("group:editor")
        root = self.app.root("editor")

# Path: nive_cms/tests/db_app.py
# def app_db(confs=None):
# def app_nodb():
# def emptypool(app):
# def createpool(path,app):
# def root(a):
# def create_page(c, user):
# def create_box(c, user):
# def create_column(c, user):
# def create_file(c, user):
# def create_image(c, user):
# def create_media(c, user):
# def create_note(c, user):
# def create_text(c, user):
# def create_spacer(c, user):
# def create_link(c, user):
# def create_menublock(c, user):
# def create_code(c, user):
# def create_news(c, user):
# 
# Path: nive_cms/tests/__local.py
# WIN = sys.platform.startswith("win")
#     ROOT = "c:\\Temp\\nive_cms\\"
#     ROOT = "/var/tmp/nive_cms/"
# DB_CONF = DatabaseConf(
#     dbName = ROOT+"cms.db",
#     fileRoot = ROOT,
#     context = "Sqlite3"
# )
# MYSQL_CONF = DatabaseConf(
#     context = "MySql",
#     dbName = "ut_nive_cms",
#     host = "localhost",
#     user = "root",
#     password = "",
#     port = "",
#     fileRoot = ROOT
# )
# POSTGRES_CONF = DatabaseConf(
#     context = "PostgreSql",
#     dbName = "ut_nive_cms",
#     host = "localhost",
#     user = "postgres",
#     password = "postgres",
#     port = "",
#     fileRoot = ROOT
# )
# ENABLE_SQLITE_TESTS = True
# ENABLE_MYSQL_TESTS = False
# ENABLE_POSTGRES_TESTS = False
#     class SqliteTestCase(unittest.TestCase):
#     class SqliteTestCase(object):
#     class MySqlTestCase(unittest.TestCase):
#     class MySqlTestCase(object):
#     class PostgreSqlTestCase(unittest.TestCase):
#     class PostgreSqlTestCase(object):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):
#         def _loadApp(self, mods=None):


# Path: nive_cms/extensions/tests/test_path.py
import unittest
from nive.definitions import *
from nive_cms.extensions.path import *
from nive.security import User
from nive_cms.tests import db_app
from nive.utils import language_data
from nive_cms.tests import __local

        self.assert_(fn ==    u"this_is_a_looooooooooooooooooooooooooooooooooooooo", fn)
        
        fn = p.EscapeFilename(u"This Is a loooooooooooooooooooooooooooooooong Filename")
        self.assert_(fn ==    u"this_is_a_loooooooooooooooooooooooooooooooong", fn)
        
        fn = p.EscapeFilename(u"This Is ä Filename")
        self.assert_(fn ==    u"this_is_a_filename", fn)
        
        
    def test_special_chars(self):
        p = AlternatePath()
        p.app = self.app
        
        for lang in language_data.languages:
            conf = language_data.GetConf(lang)
            if not conf.get("special_chars"):
                continue
            
            fn = p.EscapeFilename(u"test " + conf.get("special_chars"))
            self.assert_(fn.startswith(u"test"), fn)
            
        
        
class tWf(__local.DefaultTestCase):

    def setUp(self):
        self._loadApp()
        user = self.user = User(u"test")
        user.groups.append("group:editor")
        root = self.app.root("editor")

        self.page0 = db_app.create_page(root, user)