# Path: ckanext/dcatapit/tests/utils.py
# def get_voc_file(fname):
#     return _get_base_file(fname, 'vocabularies')
# 
# SKOS_THEME_FILE = 'data-theme-skos.rdf'
# 
# def get_test_file(fname):
#     return os.path.join(os.path.dirname(__file__), 'files', fname)
# 
# def load_graph(path=None, url=None):
#     if (not path and not url) or (path and url):
#         raise ValueError('You should provide either path or url')
# 
#     from ckanext.dcat.profiles import namespaces
# 
#     g = Graph()
#     for prefix, namespace in namespaces.items():
#         g.bind(prefix, namespace)
# 
#     if url:
#         g.parse(location=url)
#     else:
#         g.parse(source=path)
# 
#     return g


import os
import nose
import pytest
import ckanext.dcatapit.helpers as helpers
from ckanext.dcatapit.tests.utils import get_voc_file, SKOS_THEME_FILE, get_test_file, load_graph
    from ckanext.dcatapit.commands.vocabulary import EUROPEAN_THEME_NAME, do_load
    # Load themes voc

    do_load(load_graph(path=get_test_file(SKOS_THEME_FILE)), EUROPEAN_THEME_NAME)

    # test it
    vocabularies_items = helpers.get_vocabulary_items(EUROPEAN_THEME_NAME)
    ok_(vocabularies_items)


def test_list_to_string():
    test_list = ['test1', 'test2', 'test3']
    test_string = helpers.list_to_string(test_list)
    ok_(isinstance(test_string, str))


def test_format():
    value = helpers.format('14-11-2011', '%Y-%m-%d', 'date')
    eq_(value, '2011-11-14')
    # invalid value, but valid format
    # Python on linux has different behavior with year less than 1000
    value = helpers.format('14-11-0011', '%2Y-%m-%d', 'date')
    eq_(value, '11-11-14')


def test_org_context():
    # ensure ctx are separated, and no data is leaked between them
    ctx1 = helpers.get_org_context()
    ctx1['test'] = True
    ctx2 = helpers.get_org_context()


# Path: ckanext/dcatapit/tests/utils.py
# def get_voc_file(fname):
#     return _get_base_file(fname, 'vocabularies')
# 
# SKOS_THEME_FILE = 'data-theme-skos.rdf'
# 
# def get_test_file(fname):
#     return os.path.join(os.path.dirname(__file__), 'files', fname)
# 
# def load_graph(path=None, url=None):
#     if (not path and not url) or (path and url):
#         raise ValueError('You should provide either path or url')
# 
#     from ckanext.dcat.profiles import namespaces
# 
#     g = Graph()
#     for prefix, namespace in namespaces.items():
#         g.bind(prefix, namespace)
# 
#     if url:
#         g.parse(location=url)
#     else:
#         g.parse(source=path)
# 
#     return g


# Path: ckanext/dcatapit/tests/test_helpers.py
import os
import nose
import pytest
import ckanext.dcatapit.helpers as helpers
from ckanext.dcatapit.tests.utils import get_voc_file, SKOS_THEME_FILE, get_test_file, load_graph
    from ckanext.dcatapit.commands.vocabulary import EUROPEAN_THEME_NAME, do_load

    # Load themes voc

    do_load(load_graph(path=get_test_file(SKOS_THEME_FILE)), EUROPEAN_THEME_NAME)

    # test it
    vocabularies_items = helpers.get_vocabulary_items(EUROPEAN_THEME_NAME)
    ok_(vocabularies_items)


def test_list_to_string():
    test_list = ['test1', 'test2', 'test3']
    test_string = helpers.list_to_string(test_list)
    ok_(isinstance(test_string, str))


def test_format():
    value = helpers.format('14-11-2011', '%Y-%m-%d', 'date')
    eq_(value, '2011-11-14')
    # invalid value, but valid format
    # Python on linux has different behavior with year less than 1000
    value = helpers.format('14-11-0011', '%2Y-%m-%d', 'date')
    eq_(value, '11-11-14')


def test_org_context():
    # ensure ctx are separated, and no data is leaked between them
    ctx1 = helpers.get_org_context()
    ctx1['test'] = True
    ctx2 = helpers.get_org_context()


    assert ctx2.get('test') is None