view test/test_memorydb.py @ 7695:2be7a8f66ea7

fix: windows install using pip mislocates share directory The setup code that tries to make the share install path absolute prependeds something like: c:\program files\python_venv to the paths. The equivalent on linux is recognized as an absolute path. On windows this is treated oddly. This resulted in the share files being placed in: c:\program files\python_venv\Lib\site-packages\program files\python_venv\share Roundup was unable to find the files there. On windows (where the platform starts with 'win') don't make the path absolute. This puts share in: c:\program files\python_venv\Lib\share and Roundup finds them. The translations and templates are found by the roundup-server. The docs are also installed under the share directory. The man pages are not installed as windows doesn't have groff to format the source documents. This is the second fix from issues getting Roundup running on windows discussed on mailing list by Simon Eigeldinger. Thread starts with: https://sourceforge.net/p/roundup/mailman/message/41557096/ subject: Installing Roundup on Windows 2023-10-05.
author John Rouillard <rouilj@ieee.org>
date Sun, 05 Nov 2023 23:01:29 -0500
parents 2ce855803633
children
line wrap: on
line source

import unittest, os, shutil, time

from roundup import hyperdb

from .db_test_base import DBTest, ROTest, SchemaTest, config, setupSchema
from roundup.test import memorydb

from roundup.anypy import strings

class memorydbOpener:
    module = memorydb

    def nuke_database(self):
        # really kill it
        memorydb.db_nuke('')
        self.db = None

    db = None
    def open_database(self, user='admin'):
        if self.db:
            self.db.close()
        self.db = self.module.Database(config, user)
        return self.db

    def setUp(self):
        self.open_database()
        setupSchema(self.db, 1, self.module)

    def tearDown(self):
        if self.db is not None:
            self.db.close()
            self.db = None
        self.nuke_database()

    # nuke and re-create db for restore
    def nukeAndCreate(self):
        self.db.close()
        self.nuke_database()
        self.db = self.module.Database(config, 'admin')
        setupSchema(self.db, 0, self.module)


class memorydbDBTest(memorydbOpener, DBTest, unittest.TestCase):
    pass


class memorydbROTest(memorydbOpener, ROTest, unittest.TestCase):
    def setUp(self):
        self.db = self.module.Database(config)
        setupSchema(self.db, 0, self.module)


class memorydbSchemaTest(memorydbOpener, SchemaTest, unittest.TestCase):
    pass


from .session_common import SessionTest
class memorydbSessionTest(memorydbOpener, SessionTest, unittest.TestCase):
    s2b = lambda x,y: strings.s2b(y)

    def setUp(self):
        self.db = self.module.Database(config, 'admin')
        setupSchema(self.db, 1, self.module)
        self.sessions = self.db.sessions
        self.db.Session = self.sessions
        self.otks = self.db.otks
        self.db.Otk = self.otks

    def get_ts(self):
        return (self.sessions.get('random_session', '__timestamp'),)

    def testDbType(self):
        self.assertIn("memorydb", repr(self.db))
        self.assertIn("{}", repr(self.db.Session))

# vim: set filetype=python ts=4 sw=4 et si


Roundup Issue Tracker: http://roundup-tracker.org/