Exemplo n.º 1
0
    def test_args_config(self):
        with write(self.o) as (f_config, f_spec):
            c = configure(["--config", f_config.name] + self.a)
            c_ = {
                'version': [1, "RELEASE"],
                'node': {
                    'host': '127.0.0.1'
                },
                'sns': [
                    {
                        'topic': "one",
                        "enabled": True
                    },
                    {
                        'topic': "two",
                        "enabled": True
                    },
                ],
                'config':
                f_config.name,
            }

            self.assertEqual(c['version'], c_['version'])
            self.assertEqual(c['sns'], c_['sns'])
            self.assertEqual(c['node'], c_['node'])
            self.assertEqual(c['config'], c_['config'])
Exemplo n.º 2
0
 def test_json_config(self):
     c_ = {'a': 1, 'b': {'ba': 2, 'bb': "three"}}
     o = json.dumps(c_)
     with write(o, configext='.yaml') as (f_config, f_spec):
         c = configure(["--config", f_config.name])
         c_['config'] = f_config.name
         self.assertEqual(c, c_)
Exemplo n.º 3
0
 def test_args(self):
     c = configure(self.a)
     c_ = {
         'version': [1],
         'node': {
             'host': '127.0.0.1',
         },
         'sns': [Missing, {
             "enabled": True
         }]
     }
     self.assertEqual(c, c_)
Exemplo n.º 4
0
 def test_configure_option(self):
     with write(self.o) as (f_config, f_spec):
         c = configure(["--config", f_config.name])
         c_ = {
             'version': (Missing, "RELEASE"),
             'sns': [
                 {
                     'topic': "one",
                     "enabled": True
                 },
                 {
                     'topic': "two"
                 },
             ],
             'config': f_config.name
         }
         self.assertEqual(c['version'], c_['version'])
         self.assertEqual(c['sns'], c_['sns'])
         self.assertEqual(c['config'], c_['config'])
Exemplo n.º 5
0
 def test_spec(self):
     with write(self.o, self.s) as (f_config, f_spec):
         c = configure(["--config", f_config.name, "--spec", f_spec.name])
         c_ = {
             'version': (0, "RELEASE"),
             'node': {
                 'host': 'localhost',
                 'port': 8888
             },
             'sns': [
                 {
                     'topic': "one",
                     "enabled": True
                 },
                 {
                     'topic': "two",
                     "enabled": False
                 },
             ]
         }
         self.assertEqual(c, c_)
Exemplo n.º 6
0
            def not_enabled(*args, **kwargs):
                return {
                    "status": "failure",
                    "reason": "destructive operations not enabled"
                }

            app.json_route(prefix + "/:table", method=["PUT"])(not_enabled)
            app.json_route(prefix + "/:table", method=["DELETE"])(not_enabled)
            app.json_route(prefix + "/:table", method=["PATCH"])(not_enabled)

    return app


def error_handler(exception):
    # add AJAX headers
    ajax_headers(bottle.request, bottle.response)

    # print exception string
    e = exception.exception
    return e.__class__.__name__ + ": " + str(e)


if __name__ == '__main__':
    spec = os.path.join(os.path.split(__file__)[0], "config.spec.py")
    config = configurati.configure(spec=spec)

    init_logging()

    main(config)
Exemplo n.º 7
0
        return {
            "status": "failure",
            "reason": "destructive operations not enabled"
        }
      app.json_route(prefix + "/:table", method=["PUT"])(not_enabled)
      app.json_route(prefix + "/:table", method=["DELETE"])(not_enabled)
      app.json_route(prefix + "/:table", method=["PATCH"])(not_enabled)

  return app


def error_handler(exception):
  # add AJAX headers
  ajax_headers(bottle.request, bottle.response)

  # print exception string
  e = exception.exception
  return e.__class__.__name__ + ": " + str(e)


if __name__ == '__main__':
  spec = os.path.join(
    os.path.split(__file__)[0],
    "config.spec.py"
  )
  config = configurati.configure(spec=spec)

  init_logging()

  main(config)
Exemplo n.º 8
0
from pprint import pprint
from configurati import configure

pprint(configure(config='config.py', spec='spec.py'))