# Path: nive_cms/workflow/view.py
# class WorkflowEdit(Editor):
# 
#     def widget(self):
#         wf = self.context.GetWfInfo(self.User())
#         return {u"wf": wf}   
#     
#     def workflow(self):
#         wf = self.context.GetWfInfo(self.User())
#         return {u"wf": wf,u"content": u"", u"result": True, u"cmsview":self, u"head": u""}
# 
#     def action(self):
#         transition = self.GetFormValue(u"t")
#         url = self.GetFormValue("redirect_url")
#         if not url:
#             url = self.PageUrl()
#             
#         user = self.User()
#         self.context.WfAction("", user, transition=transition)
#         self.context.CommitInternal(user)
#         msg = _(u"OK")
#         self.Redirect(url, messages=[msg])
#         
#     def publishRecursive(self):
#         msgs = []
#         ok = 0
#         user = self.User()
#         
#         def recursive(self, page, ok):
#             for p in page.GetPages(includeMenu=1):
#                 if not p.meta.pool_state:
#                     try:
#                         p.WfAction("publish", user)
#                         p.CommitInternal(user)
#                         msgs.append("Published: " + p.meta.title)
#                         ok += 1
#                     except Exception, e:
#                         msgs.append(u"Failure: "+str(e))
#                         pass
#                 ok = recursive(self, p, ok)
#             return ok
#         
#         ok = recursive(self, self.context, ok)
#              
#         url = self.GetFormValue("redirect_url")
#         if not url:
#             url = self.PageUrl()
#         msgs.insert(0, "%d pages published!"%ok)
#         self.Redirect(url, messages=msgs)
# 
# Path: nive_cms/workflow/wf.py
# def publish(transition, context, user, values):
# def revoke(transition, context, user, values):
# 
# 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 pyramid import testing
from pyramid.httpexceptions import HTTPFound
from pyramid.renderers import render
from nive.security import User
from nive_cms.cmsview.view import *
from nive_cms.workflow.view import WorkflowEdit
from nive_cms.workflow import wf
from nive_cms.tests import __local 
from nive_cms.tests.db_app import *
class tWf(__local.DefaultTestCase):

    def setUp(self):
        request = testing.DummyRequest()
        request._LOCALE_ = "en"
        request.content_type = ""
        self.config = testing.setUp(request=request)
        self.config.include('pyramid_chameleon')
        self.request = request
        self._loadApp(["nive_cms.workflow.wf.wfProcess", "nive_cms.workflow.view"])
        self.app.Startup(self.config)
        self.root = self.app.root()
        user = User(u"test")
        user.groups.append("group:editor")
        self.page = create_page(self.root, user)
        self.request.context = self.page

    def tearDown(self):
        user = User(u"test")
        testing.tearDown()
        root = self.app.root()
        self.root.Delete(self.page.id, user=user)
        self.app.Close()


    def test_functions(self):
        user = User(u"test")
        user.groups.append("group:editor")
        wf.publish(None, self.page, user, {})
        self.assert_(self.page.meta.pool_state==1)

# Path: nive_cms/workflow/view.py
# class WorkflowEdit(Editor):
# 
#     def widget(self):
#         wf = self.context.GetWfInfo(self.User())
#         return {u"wf": wf}   
#     
#     def workflow(self):
#         wf = self.context.GetWfInfo(self.User())
#         return {u"wf": wf,u"content": u"", u"result": True, u"cmsview":self, u"head": u""}
# 
#     def action(self):
#         transition = self.GetFormValue(u"t")
#         url = self.GetFormValue("redirect_url")
#         if not url:
#             url = self.PageUrl()
#             
#         user = self.User()
#         self.context.WfAction("", user, transition=transition)
#         self.context.CommitInternal(user)
#         msg = _(u"OK")
#         self.Redirect(url, messages=[msg])
#         
#     def publishRecursive(self):
#         msgs = []
#         ok = 0
#         user = self.User()
#         
#         def recursive(self, page, ok):
#             for p in page.GetPages(includeMenu=1):
#                 if not p.meta.pool_state:
#                     try:
#                         p.WfAction("publish", user)
#                         p.CommitInternal(user)
#                         msgs.append("Published: " + p.meta.title)
#                         ok += 1
#                     except Exception, e:
#                         msgs.append(u"Failure: "+str(e))
#                         pass
#                 ok = recursive(self, p, ok)
#             return ok
#         
#         ok = recursive(self, self.context, ok)
#              
#         url = self.GetFormValue("redirect_url")
#         if not url:
#             url = self.PageUrl()
#         msgs.insert(0, "%d pages published!"%ok)
#         self.Redirect(url, messages=msgs)
# 
# Path: nive_cms/workflow/wf.py
# def publish(transition, context, user, values):
# def revoke(transition, context, user, values):
# 
# 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/workflow/tests/test_views.py
import unittest
from pyramid import testing
from pyramid.httpexceptions import HTTPFound
from pyramid.renderers import render
from nive.security import User
from nive_cms.cmsview.view import *
from nive_cms.workflow.view import WorkflowEdit
from nive_cms.workflow import wf
from nive_cms.tests import __local 
from nive_cms.tests.db_app import *

class tWf(__local.DefaultTestCase):

    def setUp(self):
        request = testing.DummyRequest()
        request._LOCALE_ = "en"
        request.content_type = ""
        self.config = testing.setUp(request=request)
        self.config.include('pyramid_chameleon')
        self.request = request
        self._loadApp(["nive_cms.workflow.wf.wfProcess", "nive_cms.workflow.view"])
        self.app.Startup(self.config)
        self.root = self.app.root()
        user = User(u"test")
        user.groups.append("group:editor")
        self.page = create_page(self.root, user)
        self.request.context = self.page

    def tearDown(self):
        user = User(u"test")
        testing.tearDown()
        root = self.app.root()
        self.root.Delete(self.page.id, user=user)
        self.app.Close()


    def test_functions(self):
        user = User(u"test")
        user.groups.append("group:editor")
        wf.publish(None, self.page, user, {})
        self.assert_(self.page.meta.pool_state==1)

        wf.revoke(None, self.page, user, {})