This repository shows an example of TDD practice.
As a Product Owner I want to have functionality to create new User
User should have the following fields:
- id: string
- email: string
- first_name: string
- middle_name: string
- last_name: string
- initial_name: string
Any punctuation characters from fullname is removed.
For example:
-
Richard M Stallman > RMS
-
Rama > R
-
Ebet Kadarusman > EK
-
Ricardo Izecson dos Santos Leite > RIDSL
-
Robert Downey, Jr > RDJ
- First Name, Middle Name, and Last Name is from first, second, and third words of the name, if the fullname consists of 3 words.
- Middle Name is empty string if fullname consists of 1 or 2 words.
- Last Name is always the last words of the fullname.
- Middle Name is filled with any names between firstname and lastname
Examples:
Fullname: Deodatus Andreas Deddy Cahyadi Sunjoyo
-
Firstname: Deodatus
-
Middlename: Andreas Deddy Cahyadi
-
Lastname: Sunjoyo
Fullname: Akira Toriyama
-
Firstname: Akira
-
Middlename:
-
Lastname: Toriyama
Fullname: Rudy
-
Firstname: Rudy
-
Middlename:
-
Lastname:
Data will be sent to the server in the following format in JSON
{
"fullname": "Hisma Mulya Sudradjat",
"email": "some@email.com"
}
Upon completion server will return in JSON format
{
"status": "ok",
"data": {
"id": "3bb656e9-6b4f-489f-87ba-0eed08282e26",
"email": "hisma.mulya@gmail.com",
"first_name": "Hisma",
"middle_name": "Mulya",
"last_name": "Sudradjat",
"initial_name": "HMS"
}
}
-
Python version 3.8 or above
-
pip
-
fastapi
-
uvicorn
-
GNU make
pip install -r requirements.txt
Running all tests.
make test
Running per test module, let's say we want to test test_user_initial_name
module.
pytest -vv example/tests/test_user_initial_name.py
Run the application withoud hot reloading
make run
Run the application with hot reloading
make run_dev
MIT