Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 2.54 KB

starting-a-new-impl-step-1.md

File metadata and controls

41 lines (29 loc) · 2.54 KB

Step 1. Write a simple API class with tests

Here are the tests that you want to pass (pseudo code):

test_averageRainfallForGreatBritainFrom1980to1999Exists()
    assert climateApi.getAveAnnualRainfall(1980, 1999, "gbr") == 988.8454972331015

test_averageRainfallForFranceFrom1980to1999Exists()
    assert climateApi.getAveAnnualRainfall(1980, 1999, "fra") == 913.7986955122727

test_averageRainfallForEgyptFrom1980to1999Exists()
    assert climateApi.getAveAnnualRainfall(1980, 1999, "egy") == 54.58587712129825

test_averageRainfallForGreatBritainFrom1985to1995DoesNotExist()
    climateApi.getAveAnnualRainfall(1985, 1995, "gbr")
    ... causes "date range not supported" 

test_averageRainfallForMiddleEarthFrom1980to1999DoesNotExist()
    climateApi.getAveAnnualRainfall(1980, 1999, "mde")
    ... causes "bad country code"

And the URLs you're trying to hit is https://servirtium.github.io/worldbank-climate-recordings/climateweb/rest/v1/country/annualavg/pr/{fromCCYY}/{toCCYY}/{countryISO}.xml. Which is a recording of http://climatedataapi.worldbank.org/climateweb/rest/v1/country/annualavg/pr/{fromCCYY}/{toCCYY}/{countryISO}.xml (which is down temporarily).

Endpoints we use:

Note that there is nothing of Servirtium in this initial step - this is just creation of a "test harness" in your language's preferred test runner (and following best practices including separation of prod code and test code, and a build script if necessary).

Diagram of components/services

image