Example #1
0
 def __init__(self, config_file=None):
     self.port = 8000
     self.databases = None
     self.cookie_secret = None
     if not config_file:
         config_file = os.path.join(get_mag_path(), 'server',
                                    'defaultconfig.json')
     self.config_file_path = config_file
     self.load_json()
     if not getattr(self, 'cookie_secret', None):
         self.cookie_secret = make_cookie_secret()
     if not getattr(self, 'databases', None):
         self.databases = {"default": {"ENGINE": "mongodb", "NAME": "vmr"}}
Example #2
0
File: config.py Project: zeth/magpy
 def __init__(self, config_file=None):
     self.port = 8000
     self.databases = None
     self.cookie_secret = None
     if not config_file:
         config_file = os.path.join(
             get_mag_path(), 'server', 'defaultconfig.json')
     self.config_file_path = config_file
     self.load_json()
     if not getattr(self, 'cookie_secret', None):
         self.cookie_secret = make_cookie_secret()
     if not getattr(self, 'databases', None):
         self.databases = {"default": {"ENGINE": "mongodb",
                                       "NAME": "vmr"}}
Example #3
0
    def __init__(self, *args, **kwargs):
        """
        By default, the browser emulation objects (window, localStorage etc)
        are included in JavaScript's global context.
        Set keyword argument `pure` to `True` in order to prevent inclusion.

        Use the use keyword argument `context`, to provide your own
        global context. When using the `context` argument, the browser
        emulation objects need to be explicitly added if you want them.

        Specials are JavaScript files that can be loaded by keyword.
        Use the keyword argument `specials` to override the dict of specials.
        """

        if 'pure' in kwargs:
            pure = kwargs['pure']
            del kwargs['pure']
        else:
            pure = False

        if 'context' in kwargs:
            self.session = JavascriptSession(kwargs['context'], pure)
            del kwargs['context']
        else:
            self.session = JavascriptSession(pure=pure)

        if 'specials' in kwargs:
            self.specials = kwargs['specials']
            del kwargs['specials']
        else:
            magpy_path = get_mag_path()
            self.specials = {
                "mag": os.path.join(magpy_path, 'static/js/mag.js'),
                "domcore": os.path.join(magpy_path, 'tests/js/domcore.js')
            }

        cmd.Cmd.__init__(self, *args, **kwargs)
        self.count = 1
        self.prompt_template = "In [%s]: "
        self.prompt = self.prompt_template % self.count
Example #4
0
    def __init__(self, *args, **kwargs):
        """
        By default, the browser emulation objects (window, localStorage etc)
        are included in JavaScript's global context.
        Set keyword argument `pure` to `True` in order to prevent inclusion.

        Use the use keyword argument `context`, to provide your own
        global context. When using the `context` argument, the browser
        emulation objects need to be explicitly added if you want them.

        Specials are JavaScript files that can be loaded by keyword.
        Use the keyword argument `specials` to override the dict of specials.
        """

        if 'pure' in kwargs:
            pure = kwargs['pure']
            del kwargs['pure']
        else:
            pure = False

        if 'context' in kwargs:
            self.session = JavascriptSession(kwargs['context'], pure)
            del kwargs['context']
        else:
            self.session = JavascriptSession(pure=pure)

        if 'specials' in kwargs:
            self.specials = kwargs['specials']
            del kwargs['specials']
        else:
            magpy_path = get_mag_path()
            self.specials = {
                "mag": os.path.join(magpy_path, 'static/js/mag.js'),
                "domcore": os.path.join(magpy_path, 'tests/js/domcore.js')}

        cmd.Cmd.__init__(self, *args, **kwargs)
        self.count = 1
        self.prompt_template = "In [%s]: "
        self.prompt = self.prompt_template % self.count
Example #5
0
 def setUp(self):  # pylint: disable=C0103
     super(MagTestCase, self).setUp()
     magjs = os.path.join(get_mag_path(), 'static/js/mag.js')
     self.load(magjs)
     self.eval('MAG._REQUEST._default_headers["X-UnitTest"] = "True";')
Example #6
0
 def setUp(self):  # pylint: disable=C0103
     super(MagTestCase, self).setUp()
     magjs = os.path.join(get_mag_path(), 'static/js/mag.js')
     self.load(magjs)
     self.eval('MAG._REQUEST._default_headers["X-UnitTest"] = "True";')