Example #1
0
 def declare_config_options(self, declaration: Declaration, key: Key):
     datapusher = key.ckan.datapusher
     declaration.annotate("Datapusher settings")
     declaration.declare_list(datapusher.formats, _default_formats)
     declaration.declare(datapusher.url)
     declaration.declare(datapusher.callback_url_base)
     declaration.declare_int(datapusher.assume_task_stale_after, 3600)
Example #2
0
    def test_declarations_are_gettable(self):
        decl = Declaration()
        key = Key().test
        decl.declare(key, 1)

        option = decl[key]
        assert option.default == 1
Example #3
0
    def test_make_safe_no_overrides(self):
        decl = Declaration()
        decl.declare(Key().a, 10)

        cfg = CKANConfig({"config.mode": "strict", "a": 20})
        assert decl.make_safe(cfg)
        assert cfg == CKANConfig({"config.mode": "strict", "a": 20})
Example #4
0
    def test_make_safe_in_safe_mode(self):
        decl = Declaration()
        decl.declare(Key().a, 10)

        cfg = CKANConfig({"config.mode": "strict"})
        assert decl.make_safe(cfg)
        assert cfg == CKANConfig({"config.mode": "strict", "a": 10})
Example #5
0
    def test_make_safe_no_effect(self):
        decl = Declaration()
        decl.declare(Key().a, 10)

        cfg = CKANConfig()
        assert not decl.make_safe(cfg)
        assert cfg == CKANConfig()
Example #6
0
    def declare_config_options(self, declaration: Declaration, key: Key):
        section = key.ckan.preview

        declaration.annotate("image_view settings")
        declaration.declare(
            section.image_formats, "png jpeg jpg gif").set_description(
                "Customize which image formats the image_view plugin will show"
            )
Example #7
0
    def test_basic_iteration(self):
        key = Key()
        decl = Declaration()
        decl.annotate("Start")

        decl.declare(key.a)
        decl.declare(key.b)

        assert list(decl.iter_options()) == [key.a, key.b]
Example #8
0
    def declare_config_options(self, declaration: Declaration, key: Key):
        section = key.ckan.datatables

        declaration.annotate("datatables_view settings")

        declaration.declare_list(section.page_length_choices, [
            20, 50, 100, 500, 1000
        ]).set_description(
            "https://datatables.net/examples/advanced_init/length_menu.html")
        declaration.declare_bool(section.state_saving, True)
        declaration.declare_int(section.state_duration, 7200)
        declaration.declare_bool(section.data_dictionary_labels, True)
        declaration.declare_int(section.ellipsis_length, 100)
        declaration.declare(section.date_format, "llll").set_description(
            "see Moment.js cheatsheet https://devhints.io/moment")
        declaration.declare(section.default_view, "table")
Example #9
0
    def declare_config_options(self, declaration: Declaration, key: Key):
        section = key.ckan.preview

        declaration.annotate("text_view settings")
        declaration.declare(section.text_formats, "text/plain txt plain")
        declaration.declare(section.xml_formats,
                            "xml rdf rdf+xml owl+xml atom rss")
        declaration.declare(section.json_formats, "json")
        declaration.declare(section.jsonp_formats, "jsonp")
Example #10
0
    def declare_config_options(self, declaration: Declaration, key: Key):
        section = key.ckan.datastore

        declaration.annotate("Datastore settings")
        declaration.declare(
            section.write_url,
            "postgresql://*****:*****@localhost/datastore_default"
        ).required()
        declaration.declare(
            section.read_url,
            "postgresql://*****:*****@localhost/datastore_default"
        ).required()

        declaration.declare(section.sqlsearch.allowed_functions_file,
                            _SQL_FUNCTIONS_ALLOWLIST_FILE)
        declaration.declare_bool(section.sqlsearch.enabled, False)
        declaration.declare_int(section.search.rows_default, 100)
        declaration.declare_int(section.search.rows_max, 32000)
        declaration.declare_dynamic(section.sqlalchemy.dynamic("OPTION"))

        declaration.annotate("PostgreSQL' full-text search parameters")
        declaration.declare(section.default_fts_lang, "english")
        declaration.declare(section.default_fts_index_method, "gist")
Example #11
0
    def test_pattern_and_flag_iteration(self):
        key = Key()
        decl = Declaration()
        decl.annotate("Start")

        decl.declare(key.aloha)
        decl.declare(key.hello)
        decl.declare(key.hey).ignore()

        pattern = key.dynamic("anything")
        assert list(decl.iter_options(pattern=pattern)) == [
            key.aloha,
            key.hello,
        ]

        pattern = Pattern(key) + "he*"
        assert list(decl.iter_options(pattern=pattern)) == [key.hello]

        assert list(decl.iter_options(exclude=Flag(0))) == [
            key.aloha,
            key.hello,
            key.hey,
        ]
Example #12
0
 def declare_config_options(self, declaration: Declaration, key: Key):
     declaration.annotate("video_view settings")
     declaration.declare(key.ckan.preview.video_formats, "mp4 ogg webm")
Example #13
0
 def declare_config_options(self, declaration: Declaration, key: Key):
     declaration.annotate("audio_view settings")
     declaration.declare(key.ckan.preview.audio_formats, "wav ogg mp3")
Example #14
0
 def declare_config_options(self, declaration: Declaration, key: Key):
     declaration.annotate("recline_view settings")
     declaration.declare(key.ckan.recline.dataproxy_url,
                         "//jsonpdataproxy.appspot.com")
Example #15
0
 def test_option_make_declaration_non_empty(self):
     decl = Declaration()
     decl.declare(Key().test)
     assert decl