Пример #1
0
def myapp(modules=None):
    a = ApplicationBase()
    a.Register(appconf)
    a.Register(dbconfMySql)
    if modules:
        for m in modules:
            a.Register(m)
    p = Portal()
    p.Register(a, "nive")
    a.LoadConfiguration()
    root = DvPath(a.dbConfiguration.fileRoot)
    if not root.IsDirectory():
        root.CreateDirectories()
    try:
        a.Query("select id from pool_meta where id=1")
        a.Query("select id from data1 where id=1")
        a.Query("select id from data2 where id=1")
        a.Query("select id from data3 where id=1")
        a.Query("select id from pool_files where id=1")
        a.Query("select id from pool_sys where id=1")
        a.Query("select id from pool_groups where id=1")
    except:
        a.GetTool("nive.components.tools.dbStructureUpdater")()
    a.Startup(None)
    return a
Пример #2
0
def app_db(modules=None):
    a = ApplicationBase()
    a.Register(appconf)
    if modules:
        for m in modules:
            a.Register(m)
    p = Portal()
    p.Register(a, "nive")
    a.SetupApplication()
    dbfile = DvPath(a.dbConfiguration.dbName)
    if not dbfile.IsFile():
        dbfile.CreateDirectories()
    root = DvPath(a.dbConfiguration.fileRoot)
    if not root.IsDirectory():
        root.CreateDirectories()

    try:
        a.Query("select id from pool_meta where id=1")
        a.Query("select id from data1 where id=1")
        a.Query("select id from data2 where id=1")
        a.Query("select id from data3 where id=1")
        a.Query("select id from pool_files where id=1")
        a.Query("select id from pool_sys where id=1")
        a.Query("select id from pool_groups where id=1")
        a.Query("select title from pool_meta where id=1")
    except:
        a.GetTool("nive.tools.dbStructureUpdater")()

    # disable this to update test tables each time the tests are called
    #a.GetTool("nive.tools.dbStructureUpdater")()
    a.Startup(None)
    # this will reset all testdata
    #emptypool(a)
    return a
Пример #3
0
 def test_fncs(self):
     temp = tempfile.gettempdir()
     p = DvPath(temp)
     p.AppendDirectory("tmp_nivepathtest_000")
     p.Delete(deleteSubdirs=True)
     p.CreateDirectories()
     self.assert_(p.IsDirectory())
     p.CreateDirectoriesExcp()
     p.Rename("tmp_nivepathtest_111")
     p.AppendDirectory("tmp_nivepathtest_000")
     p.AppendDirectory("tmp_nivepathtest_000")
     p.CreateDirectories()
     self.assert_(p.IsDirectory())
     p = DvPath(temp)
     p.AppendDirectory("tmp_nivepathtest_000")
     p.Delete(deleteSubdirs=False)
     self.assert_(p.IsDirectory() == True)
     p.Delete(deleteSubdirs=True)
     self.assert_(p.IsDirectory() == False)
Пример #4
0
 def test_Get(self):
     n = self.name
     p = DvPath(n)
     self.assert_(p.GetPath() == self.base)
     self.assert_(p.GetName() == "nofile")
     self.assert_(p.GetExtension() == "txt")
     self.assert_(p.GetNameExtension() == "nofile.txt")
     self.assert_(p.GetSize() == -1)
     self.assert_(p.GetLastDirectory() == "tmp_nivepathtest_000")
     p.IsFile()
     p.IsDirectory()
     p.Exists()
     p.IsValid()