def setup_test_db(self):
        """Setup test directory with valid JSON files"""
        testdir = testutils.pick_temp_directory()
        os.mkdir(testdir + '/views')
        with open("%s/users.json" % testdir, 'w') as f:
            f.write(
                """{"admin": {"email_addr": "*****@*****.**", "desc": null, "role": "admin", "hash": "69f75f38ac3bfd6ac813794f3d8c47acc867adb10b806e8979316ddbf6113999b6052efe4ba95c0fa9f6a568bddf60e8e5572d9254dbf3d533085e9153265623", "creation_date": "2012-04-09 14:22:27.075596"}}"""
            )
        with open("%s/roles.json" % testdir, 'w') as f:
            f.write(
                """{"special": 200, "admin": 100, "user": 50, "editor": 60}""")
        with open("%s/register.json" % testdir, 'w') as f:
            f.write("""{}""")
        with open("%s/views/registration_email.tpl" % testdir, 'w') as f:
            f.write(
                """Username:{{username}} Email:{{email_addr}} Code:{{registration_code}}"""
            )
        with open("%s/views/password_reset_email.tpl" % testdir, 'w') as f:
            f.write(
                """Username:{{username}} Email:{{email_addr}} Code:{{reset_code}}"""
            )
        print("setup done in %s" % testdir)

        #jb = JsonBackend(testdir, initialize=True)
        jb = JsonBackend(testdir)

        self.__testdir = testdir
        return jb
Esempio n. 2
0
    def setup(self):
        # create test dir and populate it using the example files

        # save the directory where the unit testing has been run
        if self._starting_dir is None:
            self._starting_dir = os.getcwd()

        # create json files to be used by Cork
        self._tmproot = testutils.pick_temp_directory()
        assert self._tmproot is not None

        # purge the temporary test directory
        self.remove_temp_dir()

        self.populate_temp_dir()
        self.create_app_instance()
        self._app.reset()
        print ("Reset done")
        print ("Setup completed")
Esempio n. 3
0
    def setup(self):
        # create test dir and populate it using the example files

        # save the directory where the unit testing has been run
        if self._starting_dir is None:
            self._starting_dir = os.getcwd()

        # create json files to be used by Cork
        self._tmproot = testutils.pick_temp_directory()
        assert self._tmproot is not None

        # purge the temporary test directory
        self.remove_temp_dir()

        self.populate_temp_dir()
        self.create_app_instance()
        self._app.reset()
        print("Reset done")
        print("Setup completed")
    def setup_test_db(self):
        """Setup test directory with valid JSON files"""
        testdir = testutils.pick_temp_directory()
        os.mkdir(testdir + '/views')
        with open("%s/users.json" % testdir, 'w') as f:
            f.write("""{"admin": {"email_addr": "*****@*****.**", "desc": null, "role": "admin", "hash": "69f75f38ac3bfd6ac813794f3d8c47acc867adb10b806e8979316ddbf6113999b6052efe4ba95c0fa9f6a568bddf60e8e5572d9254dbf3d533085e9153265623", "creation_date": "2012-04-09 14:22:27.075596"}}""")
        with open("%s/roles.json" % testdir, 'w') as f:
            f.write("""{"special": 200, "admin": 100, "user": 50, "editor": 60}""")
        with open("%s/register.json" % testdir, 'w') as f:
            f.write("""{}""")
        with open("%s/views/registration_email.tpl" % testdir, 'w') as f:
            f.write("""Username:{{username}} Email:{{email_addr}} Code:{{registration_code}}""")
        with open("%s/views/password_reset_email.tpl" % testdir, 'w') as f:
            f.write("""Username:{{username}} Email:{{email_addr}} Code:{{reset_code}}""")
        print("setup done in %s" % testdir)

        #jb = JsonBackend(testdir, initialize=True)
        jb = JsonBackend(testdir)

        self.__testdir = testdir
        return jb
Esempio n. 5
0
    def setup(self):
        # create test dir and populate it using the example files

        # save the directory where the unit testing has been run
        if self._starting_dir is None:
            self._starting_dir = os.getcwd()

        # create json files to be used by Cork
        self._tmpdir = testutils.pick_temp_directory()
        assert self._tmpdir is not None
        self.populate_temp_dir()

        # change to the temporary test directory
        # cork relies on this being the current directory
        os.chdir(self._tmpdir)
        self.create_app_instance()
        self._app.reset()
        print("Reset done")
        #self._default_timeout = self._app.app.options['timeout']
        self._default_timeout = 30
        #FIXME: reset
        print("Setup completed")
Esempio n. 6
0
from nose import SkipTest
from nose.tools import assert_raises, raises, with_setup
from time import time
import mock
import os, sys
import shutil

from cork import Cork, AAAException, AuthException
from cork import Mailer
import testutils

testdir = None # Test directory
aaa = None # global Cork instance
cookie_name = None # global variable to track cookie status

tmproot = testutils.pick_temp_directory()

class RoAttrDict(dict):
    """Read-only attribute-accessed dictionary.
    Used to mock beaker's session objects
    """
    def __getattr__(self, name):
        return self[name]


class MockedAdminCork(Cork):
    """Mocked module where the current user is always 'admin'"""
    @property
    def _beaker_session(self):
        return RoAttrDict(username='******')
Esempio n. 7
0
from nose.tools import assert_raises, raises, with_setup
from time import time
import mock
import os
import shutil

from cork import Cork, JsonBackend, AAAException, AuthException
from cork import Mailer
from cork.base_backend import BackendIOException
import testutils

testdir = None  # Test directory
aaa = None  # global Cork instance
cookie_name = None  # global variable to track cookie status

tmproot = testutils.pick_temp_directory()


class RoAttrDict(dict):
    """Read-only attribute-accessed dictionary.
    Used to mock beaker's session objects
    """
    def __getattr__(self, name):
        return self[name]


class MockedAdminCork(Cork):
    """Mocked module where the current user is always 'admin'"""
    @property
    def _beaker_session(self):
        return RoAttrDict(username='******')