Skip to content

BuildCircle/superheroes-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Circle Superheroes tech test

Superheroes and Supervillains are always battling it out, but how do we know who wins? This repo exposes a FastAPI HTTP service that answers that question.

The GET /battle endpoint in superheroes_python/main.py accepts a hero and villain query parameter and returns the character that would win in a battle.

The characters and their stats are stored in a JSON file in AWS S3 - https://s3.eu-west-2.amazonaws.com/build-circle/characters.json

Setup

In order to run the project, you will need:

Once you have downloaded the repo:

  • Run pip install -r requirements.txt to install dependencies.
  • Run the API with uvicorn superheroes_python.main:app --reload
  • The tests can be run with pytest

API

GET /battle

Returns the winner of a battle between a hero and a villain.

Query parameters:

  • hero — name of the hero
  • villain — name of the villain

Example:

GET /battle?hero=Superman&villain=Joker

Task

Note: This tech test is deliberately loose. We're looking for your opinions and coding style.

Above all, Build Circle value clear, well tested code.

  1. Familiarise yourself with the code. Feel free to point out any issues or opinions you have about it. No right answers here but hopefully will drive good discussion.

  2. Currently the superheroes_python/get_characters.py function is mocked in our tests. The real implementation throws an error. Make this function work by loading and parsing the characters from a JSON document in S3 here https://s3.eu-west-2.amazonaws.com/build-circle/characters.json (bonus points for a decent test for this).

  3. Edge cases. Only the happy path is covered. Let's think about what could go wrong and write some code to handle it.

  4. Each hero usually has a nemesis. This is captured in the weakness field in the JSON. If a hero is fighting a villain that matches the villain in their weakness field their score is weakened by 1 point. Let's write some code to handle this.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages