# 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
    eq_(out['issued'], '2000-00-00')
    eq_(out['modified'], '01-02-2013')


@pytest.mark.usefixtures("with_request_context")
class ValidationTests(TestCase):

    DEFAULT_AGGR = 'ENVI'
    DEFAULT_THEME = 'ECON'

    def _get_dataset(self):
        org = factories.Organization(identifier=uuid4().hex, is_org=True, name=uuid4().hex)

        return {
            # 'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6',
            'owner_org': org['id'],
            'name': uuid4().hex,
            'identifier': str(uuid4()),
            'title': 'Dataset di test DCAT_AP-IT',
            'notes': 'dcatapit dataset di test',
            'issued': '2016-11-29',
            'modified': '2016-11-29',
            'frequency': 'UPDATE_CONT',
            'publisher_name': 'pubbo',
            'publisher_identifier': '234234234',
            'creator_name': 'test',
            'creator_identifier': '412946129',
            'holder_name': 'holdo',
            'holder_identifier': '234234234',
            'geographical_geonames_url': 'http://www.geonames.org/3181913',

# 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

    eq_(out['issued'], '2000-00-00')
    eq_(out['modified'], '01-02-2013')


@pytest.mark.usefixtures("with_request_context")
class ValidationTests(TestCase):

    DEFAULT_AGGR = 'ENVI'
    DEFAULT_THEME = 'ECON'

    def _get_dataset(self):
        org = factories.Organization(identifier=uuid4().hex, is_org=True, name=uuid4().hex)

        return {
            # 'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6',
            'owner_org': org['id'],
            'name': uuid4().hex,
            'identifier': str(uuid4()),
            'title': 'Dataset di test DCAT_AP-IT',
            'notes': 'dcatapit dataset di test',
            'issued': '2016-11-29',
            'modified': '2016-11-29',
            'frequency': 'UPDATE_CONT',
            'publisher_name': 'pubbo',
            'publisher_identifier': '234234234',
            'creator_name': 'test',
            'creator_identifier': '412946129',
            'holder_name': 'holdo',
            'holder_identifier': '234234234',
            'geographical_geonames_url': 'http://www.geonames.org/3181913',

            'language': '{ITA}',