# Path: ckanext/dcatapit/mapping.py
# def themes_to_aggr_json(themes: list) -> str:
#     aggr = []
#     for name in themes or []:
#         name = name.split('/')[-1]  # if it's a URL, only take the final name
#         aggr.append({'theme': name.upper(), 'subthemes': []})
#     return json.dumps(aggr)
# 
# def theme_aggr_to_theme_uris(aggregated_themes: list) -> list:
#     return [theme_name_to_uri(agg.get('theme')) for agg in aggregated_themes]
# 
# def theme_names_to_uris(names: list) -> list:
#     return [theme_name_to_uri(name) for name in names]
# 
# def theme_name_to_uri(theme_name: str) -> str:
#     if theme_name.startswith('http'):
#         log.warning(f'Theme name "{theme_name}" is already a URI')
#         return theme_name
#     return THEME_BASE_URI + theme_name.upper()
# 
# Path: ckanext/dcatapit/schema.py
# FIELD_THEMES_AGGREGATE = 'themes_aggregate'


from unittest import TestCase
from uuid import uuid4
from ckan.tests.helpers import call_action
from ckanext.dcatapit.mapping import themes_to_aggr_json, theme_aggr_to_theme_uris, theme_names_to_uris, \
    theme_name_to_uri
from ckanext.dcatapit.schema import FIELD_THEMES_AGGREGATE
import json
import nose
import pytest
import ckan.tests.factories as factories
import ckanext.dcatapit.plugin as plugin


def test_organization_get_helpers():
    helpers = organization_plugin.get_helpers()
    ok_(helpers.get('get_dcatapit_organization_schema', None))


def test_organization_group_controller():
    eq_(organization_plugin.group_controller(), 'organization')


def test_organization_group_types():
    eq_(organization_plugin.group_types()[0], 'organization')


def test_org_form_to_db_schema_api_create():
    schema = organization_plugin.form_to_db_schema_api_create()
    ok_(schema)


def test_org_form_to_db_schema_api_update():
    schema = organization_plugin.form_to_db_schema_api_update()
    ok_(schema)


def test_org_db_to_form_schema():
    schema = organization_plugin.db_to_form_schema()
    ok_(schema)



# Path: ckanext/dcatapit/mapping.py
# def themes_to_aggr_json(themes: list) -> str:
#     aggr = []
#     for name in themes or []:
#         name = name.split('/')[-1]  # if it's a URL, only take the final name
#         aggr.append({'theme': name.upper(), 'subthemes': []})
#     return json.dumps(aggr)
# 
# def theme_aggr_to_theme_uris(aggregated_themes: list) -> list:
#     return [theme_name_to_uri(agg.get('theme')) for agg in aggregated_themes]
# 
# def theme_names_to_uris(names: list) -> list:
#     return [theme_name_to_uri(name) for name in names]
# 
# def theme_name_to_uri(theme_name: str) -> str:
#     if theme_name.startswith('http'):
#         log.warning(f'Theme name "{theme_name}" is already a URI')
#         return theme_name
#     return THEME_BASE_URI + theme_name.upper()
# 
# Path: ckanext/dcatapit/schema.py
# FIELD_THEMES_AGGREGATE = 'themes_aggregate'


# Path: ckanext/dcatapit/tests/test_plugin.py
from unittest import TestCase
from uuid import uuid4
from ckan.tests.helpers import call_action
from ckanext.dcatapit.mapping import themes_to_aggr_json, theme_aggr_to_theme_uris, theme_names_to_uris, \
    theme_name_to_uri
from ckanext.dcatapit.schema import FIELD_THEMES_AGGREGATE
import json
import nose
import pytest
import ckan.tests.factories as factories
import ckanext.dcatapit.plugin as plugin



def test_organization_get_helpers():
    helpers = organization_plugin.get_helpers()
    ok_(helpers.get('get_dcatapit_organization_schema', None))


def test_organization_group_controller():
    eq_(organization_plugin.group_controller(), 'organization')


def test_organization_group_types():
    eq_(organization_plugin.group_types()[0], 'organization')


def test_org_form_to_db_schema_api_create():
    schema = organization_plugin.form_to_db_schema_api_create()
    ok_(schema)


def test_org_form_to_db_schema_api_update():
    schema = organization_plugin.form_to_db_schema_api_update()
    ok_(schema)


def test_org_db_to_form_schema():
    schema = organization_plugin.db_to_form_schema()
    ok_(schema)



def test_org_default_show_group_schema():