Skip to content

Commit

Permalink
Merge pull request #3 from climatepolicyradar/feature/pdct-1397-map-c…
Browse files Browse the repository at this point in the history
…ollection-to-new-json-structure

Feature/pdct 1397 map collection to new json structure
  • Loading branch information
katybaulch authored Aug 27, 2024
2 parents 56fd60f + ea19df8 commit 95bfbdd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
28 changes: 23 additions & 5 deletions gcf_data_mapper/cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
import sys

import click


@click.command()
@click.option("--name", required=True, help="The name to greet.")
@click.version_option("0.1.0", "--version", "-v", help="Show the version and exit.")
def greet(name):
"""Simple program that greets NAME."""
click.echo(f"Hello {name}!")
def wrangle_json():
"""Simple program that wrangles GCF data into bulk import format."""
click.echo("🚀 Starting the GCF data mapping process.")

try:
collection()
except Exception as e:
click.echo(f"❌ Failed to map GCF data to expected JSON. Error: {e}.")
sys.exit(1)

click.echo("✅ Finished mapping GCF data.")


def collection():
"""Map the GCF collection info to new structure.
Collection information is not currently available for GCF data, so
we will leave this function as not implemented for now.
"""
pass


if __name__ == "__main__":
greet()
wrangle_json()
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "gcf-data-mapper"
version = "0.1.0"
description = "A simple CLI tool to greet by name."
authors = ["Your Name <[email protected]>"]
version = "0.1.1"
description = "A CLI tool to wrangle GCF data into format recognised by the bulk-import tool."
authors = ["CPR-dev-team <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
packages = [{ include = "gcf_data_mapper" }]
Expand Down
26 changes: 26 additions & 0 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from click.testing import CliRunner

from gcf_data_mapper.cli import wrangle_json


def test_version():
runner = CliRunner()
result = runner.invoke(wrangle_json, ["--version"])
assert result.exit_code == 0
assert "version" in result.output.strip()


@pytest.mark.skip()
def test_wrangle_json_fail():
runner = CliRunner()
result = runner.invoke(wrangle_json)
assert result.exit_code == 1
assert "Failed to map GCF data to expected JSON" in result.output.strip()


def test_wrangle_json_success():
runner = CliRunner()
result = runner.invoke(wrangle_json)
assert result.exit_code == 0
assert "Finished mapping GCF data." in result.output.strip()
10 changes: 0 additions & 10 deletions tests/unit_tests/test_say_hi.py

This file was deleted.

0 comments on commit 95bfbdd

Please sign in to comment.