Beispiel #1
0
def test_data_language_roads(road_table):
    username, layername = road_table
    # print(f"username={username}, layername={layername}")
    col_names = db.get_text_column_names(username, layername)
    assert set(col_names) == set([
        'cislouseku',
        'dpr_smer_p',
        'etah1',
        'etah2',
        'etah3',
        'etah4',
        'fid_zbg',
        'jmeno',
        'kruh_obj_k',
        'kruh_obj_p',
        'peazkom1',
        'peazkom2',
        'peazkom3',
        'peazkom4',
        'r_indsil7',
        'silnice',
        'silnice_bs',
        'typsil_k',
        'typsil_p',
        'vym_tahy_k',
        'vym_tahy_p'
    ])
    langs = db.get_text_languages(username, layername)
    assert langs == ['cze']
Beispiel #2
0
def test_populated_places_table(populated_places_table):
    username, layername = populated_places_table
    print(f"username={username}, layername={layername}")
    col_names = db.get_text_column_names(username, layername)
    assert len(col_names) == 31
    langs = db.get_text_languages(username, layername)
    assert set(langs) == set(['chi', 'eng', 'rus'])
Beispiel #3
0
def test_data_language_countries(country_table):
    workspace, layername = country_table
    # print(f"username={username}, layername={layername}")
    with layman.app_context():
        col_names = db.get_text_column_names(workspace, layername)
    assert len(col_names) == 63
    with layman.app_context():
        langs = db.get_text_languages(workspace, layername)
    assert set(langs) == set([
        'ara',
        'ben',
        'chi',
        'eng',
        'fre',
        'gre',
        'hin',
        'hun',
        'jpn',
        'kor',
        'pol',
        'por',
        'rus',
        'tur',
        'vie',
    ])
Beispiel #4
0
def test_data_language_countries2(country110m_table):
    username, layername = country110m_table
    # print(f"username={username}, layername={layername}")
    # col_names = db.get_text_column_names(username, layername)
    # print(col_names)
    # assert len(col_names) == 63
    langs = db.get_text_languages(username, layername)
    assert set(langs) == set(['eng'])
Beispiel #5
0
def test_data_language_countries2(country110m_table):
    workspace, layername = country110m_table
    # print(f"username={username}, layername={layername}")
    # col_names = db.get_text_column_names(username, layername)
    # print(col_names)
    # assert len(col_names) == 63
    with layman.app_context():
        langs = db.get_text_languages(workspace, layername)
    assert set(langs) == set(['eng'])
Beispiel #6
0
def test_populated_places_table(populated_places_table):
    workspace, layername = populated_places_table
    print(f"workspace={workspace}, layername={layername}")
    with layman.app_context():
        col_names = db.get_text_column_names(workspace, layername)
    assert len(col_names) == 31
    with layman.app_context():
        langs = db.get_text_languages(workspace, layername)
    assert set(langs) == set(['chi', 'eng', 'rus'])
Beispiel #7
0
def test_data_language(boundary_table):
    username, layername = boundary_table
    # print(f"username={username}, layername={layername}")
    col_names = db.get_text_column_names(username, layername)
    assert set(col_names) == set(['featurecla', 'name', 'name_alt'])
    text_data, _ = db.get_text_data(username, layername)
    # print(f"num_rows={num_rows}")
    assert len(text_data) == 1
    assert text_data[0].startswith(' '.join(['International boundary (verify)'] * 100))
    langs = db.get_text_languages(username, layername)
    assert langs == ['eng']
Beispiel #8
0
def get_template_path_and_values(workspace, layername, http_method=None):
    assert http_method in [common.REQUEST_METHOD_POST, common.REQUEST_METHOD_PATCH]
    publ_info = get_publication_info(workspace, LAYER_TYPE, layername, context={
        'keys': ['title', 'bounding_box', 'description'],
    })
    title = publ_info['title']
    abstract = publ_info.get('description')
    bbox_3857 = publ_info.get('bounding_box')
    if bbox_util.is_empty(bbox_3857):
        bbox_3857 = settings.LAYMAN_DEFAULT_OUTPUT_BBOX
    extent = bbox_util.transform(tuple(bbox_3857), epsg_from=3857, epsg_to=4326)

    uuid_file_path = get_publication_uuid_file(LAYER_TYPE, workspace, layername)
    publ_datetime = datetime.fromtimestamp(os.path.getmtime(uuid_file_path))
    revision_date = datetime.now()
    md_language = next(iter(common_language.get_languages_iso639_2(' '.join([
        title or '',
        abstract or ''
    ]))), None)
    try:
        languages = db.get_text_languages(workspace, layername)
    except LaymanError:
        languages = []
    try:
        scale_denominator = db.guess_scale_denominator(workspace, layername)
    except LaymanError:
        scale_denominator = None

    prop_values = _get_property_values(
        workspace=workspace,
        layername=layername,
        uuid=get_layer_uuid(workspace, layername),
        title=title,
        abstract=abstract or None,
        publication_date=publ_datetime.strftime('%Y-%m-%d'),
        revision_date=revision_date.strftime('%Y-%m-%d'),
        md_date_stamp=date.today().strftime('%Y-%m-%d'),
        identifier=url_for('rest_workspace_layer.get', workspace=workspace, layername=layername),
        identifier_label=layername,
        extent=extent,
        wms_url=wms.get_wms_url(workspace, external_url=True),
        wfs_url=wfs.get_wfs_url(workspace, external_url=True),
        md_organisation_name=None,
        organisation_name=None,
        md_language=md_language,
        languages=languages,
        scale_denominator=scale_denominator,
        epsg_codes=settings.LAYMAN_OUTPUT_SRS_LIST,
    )
    if http_method == common.REQUEST_METHOD_POST:
        prop_values.pop('revision_date', None)
    template_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'record-template.xml')
    return template_path, prop_values
Beispiel #9
0
def test_data_language_countries(country_table):
    username, layername = country_table
    # print(f"username={username}, layername={layername}")
    col_names = db.get_text_column_names(username, layername)
    assert len(col_names) == 63
    langs = db.get_text_languages(username, layername)
    assert set(langs) == set([
        'ara',
        'ben',
        'chi',
        'dut',
        'eng',
        'fre',
        'ger',
        'gre',
        'hin',
        'hun',
        'jpn',
        'kor',
        'pol',
        'rus',
        'spa',
        'vie',
    ])