# Path: tests/context.py

# 
# Path: pydatajson/documentation.py
# def field_to_markdown(field):
#     """Genera texto en markdown a partir de los metadatos de un `field`.
# 
#     Args:
#         field (dict): Diccionario con metadatos de un `field`.
# 
#     Returns:
#         str: Texto que describe un `field`.
#     """
#     if "title" in field:
#         field_title = "**{}**".format(field["title"])
#     else:
#         raise Exception("Es necesario un `title` para describir un campo.")
# 
#     field_type = " ({})".format(field["type"]) if "type" in field else ""
#     field_desc = ": {}".format(
#         field["description"]) if "description" in field else ""
# 
#     text_template = "{title}{type}{description}"
#     text = text_template.format(title=field_title, type=field_type,
#                                 description=field_desc)
# 
#     return text
# 
# Path: pydatajson/documentation.py
# def distribution_to_markdown(distribution):
#     """Genera texto en markdown a partir de los metadatos de una
#     `distribution`.
# 
#     Args:
#         distribution (dict): Diccionario con metadatos de una
#         `distribution`.
# 
#     Returns:
#         str: Texto que describe una `distribution`.
#     """
#     text_template = """
# ### {title}
# 
# {description}
# 
# #### Campos del recurso
# 
# {fields}
# """
# 
#     if "field" in distribution:
#         fields = "- " + \
#             "\n- ".join(map(field_to_markdown, distribution["field"]))
#     else:
#         fields = ""
# 
#     text = text_template.format(
#         title=distribution["title"],
#         description=distribution.get("description", ""),
#         fields=fields
#     )
# 
#     return text
# 
# Path: pydatajson/documentation.py
# def dataset_to_markdown(dataset):
#     """Genera texto en markdown a partir de los metadatos de una `dataset`.
# 
#     Args:
#         dataset (dict): Diccionario con metadatos de una `dataset`.
# 
#     Returns:
#         str: Texto que describe una `dataset`.
#     """
#     text_template = """
# # {title}
# 
# {description}
# 
# ## Recursos del dataset
# 
# {distributions}
# """
# 
#     if "distribution" in dataset:
#         distributions = "".join(
#             map(distribution_to_markdown, dataset["distribution"]))
#     else:
#         distributions = ""
# 
#     text = text_template.format(
#         title=dataset["title"],
#         description=dataset.get("description", ""),
#         distributions=distributions
#     )
# 
#     return text


import os.path
import unittest
import nose
from .context import pydatajson
from pydatajson.documentation import field_to_markdown
from pydatajson.documentation import distribution_to_markdown
from pydatajson.documentation import dataset_to_markdown
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests del modulo pydatajson."""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement



class DocumentationTestCase(unittest.TestCase):

    SAMPLES_DIR = os.path.join("tests", "samples")
    RESULTS_DIR = os.path.join("tests", "results")

    def test_field_to_markdown(self):
        field = {
            "title": "procedimiento_id",
            "type": "integer",
            "description": "Identificador único del procedimiento"
        }


# Path: tests/context.py

# 
# Path: pydatajson/documentation.py
# def field_to_markdown(field):
#     """Genera texto en markdown a partir de los metadatos de un `field`.
# 
#     Args:
#         field (dict): Diccionario con metadatos de un `field`.
# 
#     Returns:
#         str: Texto que describe un `field`.
#     """
#     if "title" in field:
#         field_title = "**{}**".format(field["title"])
#     else:
#         raise Exception("Es necesario un `title` para describir un campo.")
# 
#     field_type = " ({})".format(field["type"]) if "type" in field else ""
#     field_desc = ": {}".format(
#         field["description"]) if "description" in field else ""
# 
#     text_template = "{title}{type}{description}"
#     text = text_template.format(title=field_title, type=field_type,
#                                 description=field_desc)
# 
#     return text
# 
# Path: pydatajson/documentation.py
# def distribution_to_markdown(distribution):
#     """Genera texto en markdown a partir de los metadatos de una
#     `distribution`.
# 
#     Args:
#         distribution (dict): Diccionario con metadatos de una
#         `distribution`.
# 
#     Returns:
#         str: Texto que describe una `distribution`.
#     """
#     text_template = """
# ### {title}
# 
# {description}
# 
# #### Campos del recurso
# 
# {fields}
# """
# 
#     if "field" in distribution:
#         fields = "- " + \
#             "\n- ".join(map(field_to_markdown, distribution["field"]))
#     else:
#         fields = ""
# 
#     text = text_template.format(
#         title=distribution["title"],
#         description=distribution.get("description", ""),
#         fields=fields
#     )
# 
#     return text
# 
# Path: pydatajson/documentation.py
# def dataset_to_markdown(dataset):
#     """Genera texto en markdown a partir de los metadatos de una `dataset`.
# 
#     Args:
#         dataset (dict): Diccionario con metadatos de una `dataset`.
# 
#     Returns:
#         str: Texto que describe una `dataset`.
#     """
#     text_template = """
# # {title}
# 
# {description}
# 
# ## Recursos del dataset
# 
# {distributions}
# """
# 
#     if "distribution" in dataset:
#         distributions = "".join(
#             map(distribution_to_markdown, dataset["distribution"]))
#     else:
#         distributions = ""
# 
#     text = text_template.format(
#         title=dataset["title"],
#         description=dataset.get("description", ""),
#         distributions=distributions
#     )
# 
#     return text


# Path: tests/test_documentation.py
import os.path
import unittest
import nose
from .context import pydatajson
from pydatajson.documentation import field_to_markdown
from pydatajson.documentation import distribution_to_markdown
from pydatajson.documentation import dataset_to_markdown

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests del modulo pydatajson."""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement



class DocumentationTestCase(unittest.TestCase):

    SAMPLES_DIR = os.path.join("tests", "samples")
    RESULTS_DIR = os.path.join("tests", "results")

    def test_field_to_markdown(self):
        field = {
            "title": "procedimiento_id",
            "type": "integer",
            "description": "Identificador único del procedimiento"
        }


        result = field_to_markdown(field)