diff --git a/src/seedcase_sprout/templates/README.jinja2 b/src/seedcase_sprout/templates/README.jinja2 index 6b7b1cbd5..fc5d33071 100644 --- a/src/seedcase_sprout/templates/README.jinja2 +++ b/src/seedcase_sprout/templates/README.jinja2 @@ -14,8 +14,19 @@ {% if properties.resources -%} ## Data Resources {% for resource in properties.resources %} - {{ loop.index }}. **{{ resource.title }}**: {{ resource.description }} +### {{ resource.title }} + +{{ resource.description }} +{% if resource.schema.fields %} +| Name | Title | Type | Description | +|------|-------|------|-------------| +{%- for field in resource.schema.fields %} +| {{ field.name | inline_code }} | {{ field.title }} | {{ field.type | inline_code }} | {{ field.description }} | {%- endfor %} + +: Resource fields in {{ resource.title }} and some details about them. +{% endif %} +{%- endfor -%} {% else -%} No resources available. {% endif %} diff --git a/tests/test_as_readme_text.py b/tests/test_as_readme_text.py index 50978aaeb..97beaacac 100644 --- a/tests/test_as_readme_text.py +++ b/tests/test_as_readme_text.py @@ -1,54 +1,25 @@ from pytest import mark from seedcase_sprout import ( - ContributorProperties, - LicenseProperties, PackageProperties, - ResourceProperties, as_readme_text, + example_package_properties, + example_resource_properties_all_types, ) def test_creates_readme(): - """Should be able to create a README for a set of properties.""" - properties = PackageProperties( - name="diabetes-hypertension-study", - title="Diabetes and Hypertension Study", - homepage="www.my-page.com/diabetes-2021", - id="123-abc-123", - description="This is my package.", - version="2.0.0", - created="2024-05-14T05:00:01+00:00", - contributors=[ - ContributorProperties( - title="Jamie Jones", - email="jamie_jones@example.com", - path="example.com/jamie_jones", - roles=["creator"], - ) - ], - resources=[ - ResourceProperties( - title="First Resource", description="This is my first resource." - ), - ResourceProperties( - title="Second Resource", description="This is my second resource." - ), - ], - licenses=[ - LicenseProperties( - name="ODC-BY-1.0", - path="https://opendatacommons.org/licenses/by", - title="Open Data Commons Attribution License 1.0", - ), - LicenseProperties( - name="APL-1.0", - path="https://opensource.org/license/apl1-0-php", - title="Adaptive Public License 1.0", - ), - ], - ) - assert as_readme_text(properties) + """Should create a README with basic information about the properties.""" + properties = example_package_properties() + resource = example_resource_properties_all_types() + assert resource.schema + assert resource.schema.fields + properties.resources = [resource] + + readme = as_readme_text(properties) + + assert str(resource.title) in readme + assert all([str(field.name) in readme for field in resource.schema.fields]) def test_creates_readme_with_empty_values():