def test_schemafactory_build_complex_options(self):
        schemas = DjangoSchemaFactory()

        options = {
            'dict1': {'foo': 1, 'bar': '2'},
            'dict2': {'foo': {'bar': 2, 'baz': 3}},
            'list1': ['1', '2', '3'],
            'list2': [1, 2, 3],
        }
        expected = {
            'dict1': DictOption(name='dict1', default=options['dict1'],
                                item=StringOption()),
            'dict2': DictOption(name='dict2', default=options['dict2'],
                                item=DictOption()),
            'list1': ListOption(name='list1', default=options['list1'],
                                item=StringOption()),
            'list2': ListOption(name='list2', default=options['list2'],
                                item=IntOption()),
        }

        schema = schemas.build('foo', options)()

        sections = sorted(
            [section.name for section in schema.sections()])
        section = schema.section('django')
        self.assertEqual(sections, ['django'])

        for name in options:
            option = expected[name]
            option.section = section
            self.assertEqual(section.option(name), option)
            self.assertEqual(section.option(name).item, option.item)
Exemple #2
0
 class raven(Section):
     sentry_servers = ListOption()
     sentry_include_paths = ListOption(
         item=StringOption())
     sentry_exclude_paths = ListOption(
         item=StringOption(),
         help='Ignore module prefixes when attempting to discover which '
             'function an error comes from.')
     sentry_timeout = IntOption(
         default=5,
         help='Timeout value for sending messages to remote.')
     sentry_name = StringOption(
         null=True,
         help='This will override the server_name value for this installation.')
     sentry_auto_log_stacks = BoolOption(
         default=False,
         help='Should raven automatically log frame stacks (including '
             'locals) all calls as it would for exceptions.')
     sentry_key = StringOption(
         null=True)
     sentry_max_length_string = IntOption(
         default=200,
         help='The maximum characters of a string that should be stored.')
     sentry_max_length_list = IntOption(
         default=50,
         help='The maximum number of items a list-like container should store.')
     sentry_site = StringOption(
         null=True,
         help='An optional, arbitrary string to identify this client '
             'installation.')
     sentry_public_key = StringOption(
         null=True,
         help='Public key of the project member which will authenticate as '
             'the client.')
     sentry_private_key = StringOption(
         null=True,
         help='Private key of the project member which will authenticate as '
             'the client.')
     sentry_project = IntOption(
         default=1,
         help='Sentry project ID. The default value for installations is 1.')
     sentry_processors = ListOption(
         item=StringOption(),
         default=[
             'raven.processors.SanitizePasswordsProcessor',
             ],
         help='List of processors to apply to events before sending them '
             'to the Sentry server.')
     sentry_dsn = StringOption(
         help='A sentry compatible DSN.')
     sentry_client = StringOption(
         default='raven.contrib.django.DjangoClient')
     sentry_debug = BoolOption(
         default=False)
Exemple #3
0
 class MySchema(Schema):
     foo = ListOption(item=DictOption(
         spec={
             'bar': StringOption(),
             'baz': IntOption(),
             'bla': BoolOption(),
         }))
Exemple #4
0
 class devserver(Section):
     devserver_args = ListOption(
         item=StringOption(),
         default=[],
         help='Additional command line arguments to pass to the runserver command (as defaults).')
     devserver_default_addr = StringOption(
         default='127.0.0.1',
         help='The default address to bind to.')
     devserver_default_port = StringOption(
         default='8000',
         help='The default port to bind to.')
     devserver_wsgi_middleware = ListOption(
         item=StringOption(),
         default=[],
         help='A list of additional WSGI middleware to apply to the runserver command.')
     devserver_modules = ListOption(
         item=StringOption(),
         default=[
             'devserver.modules.sql.SQLRealTimeModule',
             ],
         help='List of devserver modules to enable')
     devserver_ignored_prefixes = ListOption(
         item=StringOption(),
         default=['/media', '/uploads'],
         help='List of prefixes to supress and skip process on. By default, '
             'ADMIN_MEDIA_PREFIX, MEDIA_URL and STATIC_URL '
             '(for Django >= 1.3) will be ignored (assuming MEDIA_URL and '
             'STATIC_URL is relative).')
     devserver_truncate_sql = BoolOption(
         default=True,
         help='Truncate SQL queries output by SQLRealTimeModule.')
     devserver_truncate_aggregates = BoolOption(
         default=False)
     devserver_active = BoolOption(
         default=False)
     devserver_ajax_content_length = IntOption(
         default=300,
         help='Maximum response length to dump.')
     devserver_ajax_pretty_print = BoolOption(
         default=False)
     devserver_sql_min_duration = IntOption(
         default=None,
         help='Minimum time a query must execute to be shown, value is in ms.')
     devserver_auto_profile = BoolOption(
         default=False,
         help='Automatically profile all view functions.')
Exemple #5
0
 class openid(Section):
     openid_use_as_admin_login = BoolOption(default=False)
     openid_create_users = BoolOption(default=False)
     openid_update_details_from_sreg = BoolOption(default=False)
     openid_physical_multifactor_required = BoolOption(default=False)
     openid_strict_usernames = BoolOption(default=False)
     openid_sreg_required_fields = ListOption(item=StringOption())
     openid_sreg_extra_fields = ListOption(item=StringOption())
     openid_follow_renames = BoolOption(default=False)
     openid_launchpad_teams_mapping_auto = BoolOption(default=False)
     openid_launchpad_teams_mapping_auto_blacklist = ListOption(
         item=StringOption())
     openid_launchpad_teams_mapping = DictOption()
     openid_launchpad_staff_teams = ListOption(item=StringOption())
     openid_disallow_inames = BoolOption(default=False)
     allowed_external_openid_redirect_domains = ListOption(
         item=StringOption())
     openid_trust_root = StringOption()
     openid_sso_server_url = StringOption(null=True)
Exemple #6
0
 class saml2(Section):
     saml2idp_autosubmit = BoolOption(default=True)
     saml2idp_issuer = StringOption(default='http://127.0.0.1:8000')
     saml2idp_certificate_file = StringOption(
         default='keys/certificate.pem')
     saml2idp_private_key_file = StringOption(
         default='keys/private-key.pem')
     saml2idp_signing = BoolOption(default=True)
     saml2idp_valid_acs = ListOption(
         item=StringOption(),
         default=[
             'https://login.salesforce.com',
         ],
         help="List of ACS URLs accepted by /+saml login")
     saml2idp_processor_classes = ListOption(
         item=StringOption(),
         default=[
             'saml2idp.salesforce.Processor',
             'saml2idp.google_apps.Processor',
         ],
         help="List of SAML 2.0 AuthnRequest processors")
 class django_jenkins(Section):
     project_apps = ListOption(
         item=StringOption(),
         default=[],
         help='List of of django apps for Jenkins to run.')
     jenkins_tasks = TupleOption(
         default=(
             'django_jenkins.tasks.run_pylint',
             'django_jenkins.tasks.with_coverage',
             'django_jenkins.tasks.django_tests',
         ),
         help='List of Jenkins tasks executed by ./manage.py jenkins '
         'command.')
     jenkins_test_runner = StringOption(
         default='',
         help='The name of the class to use for starting the test suite for '
         'jenkins and jtest commands. Class should be inherited from '
         'django_jenkins.runner.CITestSuiteRunner.')
Exemple #8
0
    def test_equal(self):
        """Test ListOption equality."""
        option1 = ListOption()
        option2 = ListOption(name='foo')
        option3 = ListOption(item=StringOption())
        option4 = ListOption(item=DictOption())
        option5 = ListOption(raw=True)
        option6 = ListOption(remove_duplicates=True)
        option7 = ListOption(raw=False, item=StringOption(raw=True))

        self.assertEqual(option1, option1)
        self.assertNotEqual(option1, option2)
        self.assertEqual(option1, option3)
        self.assertNotEqual(option1, option4)
        self.assertNotEqual(option1, option5)
        self.assertNotEqual(option1, option6)
        self.assertNotEqual(option1, option7)
 def test_to_string_when_no_json(self):
     option = ListOption(parse_json=False)
     result = option.to_string(['1', '2', '3'])
     self.assertEqual(result, "['1', '2', '3']")
 def test_to_string_when_json(self):
     option = ListOption()
     result = option.to_string(['1', '2', '3'])
     self.assertEqual(result, '["1", "2", "3"]')
     self.assertNotEqual(result, "['1', '2', '3']")
Exemple #11
0
 class MySchema(Schema):
     foo = ListOption(
         item=DictOption(
             item=ListOption(item=DictOption())))
Exemple #12
0
 def test_to_string_when_no_json(self):
     option = ListOption(parse_json=False)
     result = option.to_string(['1', '2', '3'])
     expected = [text_type(x) for x in [1, 2, 3]]
     self.assertEqual(result, text_type(expected))
Exemple #13
0
class OpenProximitySchema(Django13Schema):
    ################################################
    # openproximity general settings
    ################################################
    openproximity = Section('openproximity')
    openproximity.aircable_path = StringOption(
        default='/tmp/aircable',
        help=
        'Path were we store the database file (if using sqlite) and storing files for campaigns etc'
    )
    openproximity.op2_debug = BoolOption(
        default=True, help='Disable if you want to hide the "Databrowse" tab')
    openproximity.op2_translate = BoolOption(
        default=True, help='Disable if you want to hide the "Translate" tab')
    openproximity.op2_twitter = BoolOption(
        default=True,
        help='Disable if you want to hide the Twitter news client')
    openproximity.op2_logo = StringOption(
        default='logo.gif', help='Logo to display instead of AIRcable logo')
    openproximity.op2_plugins = DictOption(
        item=BoolOption(),
        help=
        """A list of plugins name with they're enable/disable state overrides plugins defaults)"""
    )
    openproximity.op2_scanners = ListOption(
        item=TupleOption(4),
        help=
        """A list of ([MAC filter], scanner priority) for dongle configuration on initial discovery"""
    )
    openproximity.op2_uploaders = ListOption(
        item=TupleOption(4),
        help=
        """A list of ([MAC filter], max connections) for dongle configuration on initial discovery"""
    )

    ################################################
    # cherrypy settings
    ################################################
    cherrypy = Section('cherrypy')
    cherrypy.cp_host = StringOption(default="localhost",
                                    help='hostname to listen on')
    cherrypy.cp_port = IntOption(default=8088, help='port to listen on')
    cherrypy.cp_server_name = StringOption(
        default="localhost", help="CherryPy's SERVER_NAME environ entry")
    cherrypy.cp_daemonize = BoolOption(default=False,
                                       help='whether to detach from terminal')
    cherrypy.cp_pidfile = StringOption(
        default=None, help="write the spawned process-id to this file")
    cherrypy.cp_workdir = StringOption(
        default=None, help="change to this directory when daemonizing")
    cherrypy.cp_threads = IntOption(default=20,
                                    help='Number of threads for server to use')
    cherrypy.cp_ssl_certificate = StringOption(default=None,
                                               help="SSL certificate filename")
    cherrypy.cp_ssl_private_key = StringOption(default=None,
                                               help="SSL private key filename")
    cherrypy.cp_server_user = StringOption(
        default='www-data', help="user to run daemonized process")
    cherrypy.cp_server_group = StringOption(default='www-data',
                                            help="group to daemonized process")

    ################################################
    # rpyc settings
    ################################################
    rpyc = Section('rpyc')
    rpyc.rpc_host = StringOption(default="localhost",
                                 help='hostname to listen on')
    rpyc.rpc_port = IntOption(default=8010, help='port to listen on')
    rpyc.rpc_daemonize = BoolOption(default=False,
                                    help='whether to detach from terminal')
    rpyc.rpc_threaded = BoolOption(
        default=True, help='run in threaded way instead of forked')
    rpyc.rpc_autoregister = BoolOption(
        default=False, help='try registering the server in name servers')
    rpyc.rpc_pidfile = StringOption(
        default=None, help="write the spawned process-id to this file")
    rpyc.rpc_server_user = StringOption(default='www-data',
                                        help="user to run daemonized process")
    rpyc.rpc_server_group = StringOption(default='www-data',
                                         help="group to daemonized process")

    ################################################
    # debugging settings
    ################################################
    debug = Section('debug')
    debug.debug_console = StringOption(
        default='INFO', help='console debug level, default INFO')
    debug.debug_level = StringOption(default='DEBUG',
                                     help='in file debug level, default DEBUG')
    debug.debug_path = StringOption(
        default='/var/log/openproximity',
        help='default path used for storing log files')
    debug.debug_maxsize = IntOption(default=10,
                                    help='max log file in MB, defaults to 10')
    debug.debug_count = IntOption(
        default=5,
        help='amount of log files to store when rotating, defaults to 2')
    debug.debug_filename = StringOption(
        default=None,
        help='file name used for this debug session, defaults to sys.argv[1]')
    debug.debug_console_format = StringOption(
        default='%(name)s %(module)s:%(funcName)s: %(message)s',
        help='console log formatting')
    debug.debug_format = StringOption(
        default=
        '%(asctime)-12s - %(levelname)5s - %(name)10s - %(funcName)-12s: %(message)s',
        help='file log formatting')
    debug.debug_disables = StringOption(
        default='', help='comma separated list of disable log modules')

    rpc_client = Section("rpc_client")
    rpc_client.client_mode = StringOption()
    rpc_client.client_daemonize = BoolOption(default=False)
    rpc_client.client_pidfile = StringOption(default=None)
    rpc_client.client_host = StringOption(default="localhost")
    rpc_client.client_port = IntOption(default=8010)
Exemple #14
0
 def test_to_string_when_no_json(self):
     option = ListOption(parse_json=False)
     result = option.to_string(['1', '2', '3'])
     self.assertEqual(result, "['1', '2', '3']")
Exemple #15
0
 def test_to_string_when_json(self):
     option = ListOption()
     result = option.to_string(['1', '2', '3'])
     self.assertEqual(result, '["1", "2", "3"]')
     self.assertNotEqual(result, "['1', '2', '3']")
Exemple #16
0
 class froo(Section):
     twaddle = ListOption(item=BoolOption())
Exemple #17
0
 class MySchema(Schema):
     foo = ListOption(item=TupleOption(length=3))
Exemple #18
0
 class MySchema(Schema):
     foo = ListOption(item=StringOption())
Exemple #19
0
 class MySchema(Schema):
     foo = ListOption(
         item=DictOption(spec={
             'bar': IntOption(),
             'baz': IntOption(),
         }, strict=True))
Exemple #20
0
 class MySchema(Schema):
     foo = ListOption(
         item=DictOption(spec={'bar': IntOption()}))
Exemple #21
0
 class MySchema(Schema):
     foo = ListOption(item=TupleOption(2))