# Path: ckanext/showcase/utils.py
# def markdown_to_html():
#     ''' Migrates the notes of all showcases from markdown to html.
# 
#     When using CKEditor, notes on showcases are stored in html instead of
#     markdown, this command will migrate all nothes using CKAN's
#     render_markdown core helper.
#     '''
#     showcases = tk.get_action('ckanext_showcase_list')(data_dict={})
# 
#     site_user = tk.get_action('get_site_user')({
#         'model': model,
#         'ignore_auth': True},
#         {}
#     )
#     context = {
#         'model': model,
#         'session': model.Session,
#         'ignore_auth': True,
#         'user': site_user['name'],
#     }
# 
#     for showcase in showcases:
#         tk.get_action('package_patch')(
#             context,
#             {
#                 'id': showcase['id'],
#                 'notes': h.render_markdown(showcase['notes'])
#             }
#         )
#     log.info('All notes were migrated successfully.')


import pytest
from ckan.lib import helpers
from ckan.tests import factories, helpers as test_helpers
from ckanext.showcase.utils import markdown_to_html
# -*- coding: utf-8 -*-





@pytest.mark.usefixtures("clean_db")
class TestUtils(object):

    def test_markdown_to_html(self):
        showcase1 = factories.Dataset(
                type='showcase',
                name='my-showcase',
                notes='# Title')

        showcase2 = factories.Dataset(
            type='showcase',
            name='my-showcase-2',
            notes='# Title 2')

        markdown_to_html()

        migrated_showcase1 = test_helpers.call_action(

# Path: ckanext/showcase/utils.py
# def markdown_to_html():
#     ''' Migrates the notes of all showcases from markdown to html.
# 
#     When using CKEditor, notes on showcases are stored in html instead of
#     markdown, this command will migrate all nothes using CKAN's
#     render_markdown core helper.
#     '''
#     showcases = tk.get_action('ckanext_showcase_list')(data_dict={})
# 
#     site_user = tk.get_action('get_site_user')({
#         'model': model,
#         'ignore_auth': True},
#         {}
#     )
#     context = {
#         'model': model,
#         'session': model.Session,
#         'ignore_auth': True,
#         'user': site_user['name'],
#     }
# 
#     for showcase in showcases:
#         tk.get_action('package_patch')(
#             context,
#             {
#                 'id': showcase['id'],
#                 'notes': h.render_markdown(showcase['notes'])
#             }
#         )
#     log.info('All notes were migrated successfully.')


# Path: ckanext/showcase/tests/test_utils.py
import pytest
from ckan.lib import helpers
from ckan.tests import factories, helpers as test_helpers
from ckanext.showcase.utils import markdown_to_html

# -*- coding: utf-8 -*-





@pytest.mark.usefixtures("clean_db")
class TestUtils(object):

    def test_markdown_to_html(self):
        showcase1 = factories.Dataset(
                type='showcase',
                name='my-showcase',
                notes='# Title')

        showcase2 = factories.Dataset(
            type='showcase',
            name='my-showcase-2',
            notes='# Title 2')

        markdown_to_html()

        migrated_showcase1 = test_helpers.call_action(

                'package_show',