code-challenge
code-challenge copied to clipboard
Parserator challenge
Overview
This PR consists of two major parts:
- A backend JSON API endpoint, which parses U.S. address strings using usaddress
- JavaScript for the previously built static frontend, which provides a simple form for a user to enter an address, calls the API, and renders the returned parsed address information in the UI
This PR also includes tests for the API endpoint, and a few other small fixes and adjustments (enumerated below)
Closes #XXX
Demo
Functioning app with network request:
Displaying an error message:
Tests passing
Notes
Other changes:
- Added
npmto theapt-get...line in the Dockerfile, to fix annpm not founderror when building - In the Index.html template, changed the inline
display: nonestyling on the address results div to use Bootstrap'sd-noneutility class. This maintains consistency with the rest of the page's styling, and makes manipulating the div's styling through JavaScript more straightforward. - This coding challenge was completed by me, Noah Appelbaum
Testing Instructions
How to Test
- Build with
docker-compose build - Run tests with
docker-compose -f docker-compose.yml -f tests/docker-compose.yml run --rm app
New Test Cases
-
test_api_parse_succeeds-- The API should respond successfully, with expected JSON, on a valid address -
test_api_parse_succeeds_on_empty_string-- the API should respond successfully on an empty string, consistent with the output ofusaddressand expected frontend behavior -
test_api_parse_raises_error-- The API should raise an error on an invalid address input -
test_api_parse_raises_error_on_missing_address_string-- The API should raise an error when missing address input (from a malformed request, e.g.)