Faking a Network-Service API
As it is right now, our app derives its usefulness from OpenStreetMap, a relatively simple black box. We hand it a rectangle of geographical coordinates and a search string, and it returns a JSON array of dictionaries that we parse. There’s neither authentication nor any other hoops to jump through to get the information. That makes this an ideal candidate to practice building a fake service.
We’re going to build a simple web server to return consistent JSON results given a box around a geographical point. We can make the data whatever we want, and it will never change unless we change it. We’ll then learn how to point the app at our fake server when running in the test environment. Our tests will no longer depend ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access