# 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
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)
        self.page = db_app.create_page(self.page0, user)
    
    def tearDown(self):
        user = User(u"test")
        root = self.app.root()
        root.Delete(self.page0.id, user=user)
    
    def test_automated(self):
        title = self.page.meta.title
        filename = self.page.meta.pool_filename
        self.assert_(title!=filename)
        self.assert_(filename==self.page.EscapeFilename(title), filename)

        page2 = db_app.create_page(self.page0, self.user)
        self.assert_(page2.meta.pool_filename!=filename)
        
        page3 = db_app.create_page(self.page0, self.user)
        self.assert_(page3.meta.pool_filename!=filename)
        self.assert_(page3.meta.pool_filename!=page2.meta.pool_filename)
                
        self.assert_(self.page0[filename].id==self.page.id)
        self.assert_(self.page0[filename+u".html"].id==self.page.id)

# 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

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)
        self.page = db_app.create_page(self.page0, user)
    
    def tearDown(self):
        user = User(u"test")
        root = self.app.root()
        root.Delete(self.page0.id, user=user)
    
    def test_automated(self):
        title = self.page.meta.title
        filename = self.page.meta.pool_filename
        self.assert_(title!=filename)
        self.assert_(filename==self.page.EscapeFilename(title), filename)

        page2 = db_app.create_page(self.page0, self.user)
        self.assert_(page2.meta.pool_filename!=filename)
        
        page3 = db_app.create_page(self.page0, self.user)
        self.assert_(page3.meta.pool_filename!=filename)
        self.assert_(page3.meta.pool_filename!=page2.meta.pool_filename)
                
        self.assert_(self.page0[filename].id==self.page.id)
        self.assert_(self.page0[filename+u".html"].id==self.page.id)

        self.assert_(self.page0[page2.meta.pool_filename].id==page2.id)