Beispiel #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)
Beispiel #2
0
    def declare_config_options(self, declaration: Declaration, option: Key):
        proxy = option.ckan.resource_proxy
        declaration.annotate("Resource Proxy settings")

        declaration.declare_int(proxy.max_file_size, 1048576).set_description(
            "Preview size limit, default: 1MB")
        declaration.declare_int(proxy.chunk_size, 4096).set_description(
            "Size of chunks to read/write.")
Beispiel #3
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"
            )
Beispiel #4
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")
Beispiel #5
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]
Beispiel #6
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")
Beispiel #7
0
    def test_setup(self, ckan_config):
        decl = Declaration()
        decl.setup()

        # setup seals declaration
        with pytest.raises(TypeError):
            decl.annotate("hello")

        # core declarations loaded
        assert Key().ckan.site_url in decl

        # no safe-mode by default
        missing = set(decl.iter_options()) - set(ckan_config)
        assert Key().api_token.jwt.algorithm in missing

        # no normalization by default
        assert isinstance(ckan_config["debug"], str)
Beispiel #8
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")
Beispiel #9
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,
        ]
Beispiel #10
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")
Beispiel #11
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")
Beispiel #12
0
 def declare_config_options(self, declaration: Declaration, key: Key):
     declaration.annotate("expire_api_token plugin")
     key = key.expire_api_token.default_lifetime
     declaration.declare_int(key, 3600)
Beispiel #13
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")
Beispiel #14
0
 def test_annotations_make_declaration_non_empty(self):
     decl = Declaration()
     decl.annotate("Hello")
     assert decl