mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-03-11 21:12:17 +01:00
python version of exercise
This commit is contained in:
17
python/tests/invoice.json
Normal file
17
python/tests/invoice.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"customer": "BigCo",
|
||||
"performances": [
|
||||
{
|
||||
"playID": "hamlet",
|
||||
"audience": 55
|
||||
},
|
||||
{
|
||||
"playID": "as-like",
|
||||
"audience": 35
|
||||
},
|
||||
{
|
||||
"playID": "othello",
|
||||
"audience": 40
|
||||
}
|
||||
]
|
||||
}
|
||||
13
python/tests/invoice_new_plays.json
Normal file
13
python/tests/invoice_new_plays.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"customer": "BigCoII",
|
||||
"performances": [
|
||||
{
|
||||
"playID": "henry-v",
|
||||
"audience": 53
|
||||
},
|
||||
{
|
||||
"playID": "as-like",
|
||||
"audience": 55
|
||||
}
|
||||
]
|
||||
}
|
||||
4
python/tests/new_plays.json
Normal file
4
python/tests/new_plays.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"henry-v": {"name": "Henry V", "type": "history"},
|
||||
"as-like": {"name": "As You Like It", "type": "pastoral"}
|
||||
}
|
||||
5
python/tests/plays.json
Normal file
5
python/tests/plays.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"hamlet": {"name": "Hamlet", "type": "tragedy"},
|
||||
"as-like": {"name": "As You Like It", "type": "comedy"},
|
||||
"othello": {"name": "Othello", "type": "tragedy"}
|
||||
}
|
||||
25
python/tests/test_statement.py
Normal file
25
python/tests/test_statement.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from approvaltests import verify
|
||||
from approvaltests.utils import get_adjacent_file
|
||||
|
||||
from statement import statement
|
||||
|
||||
|
||||
def test_example_statement():
|
||||
with open(get_adjacent_file("invoice.json")) as f:
|
||||
invoice = json.loads(f.read())
|
||||
with open(get_adjacent_file("plays.json")) as f:
|
||||
plays = json.loads(f.read())
|
||||
verify(statement(invoice, plays))
|
||||
|
||||
|
||||
def test_statement_with_new_play_types():
|
||||
with open(get_adjacent_file("invoice_new_plays.json")) as f:
|
||||
invoice = json.loads(f.read())
|
||||
with open(get_adjacent_file("new_plays.json")) as f:
|
||||
plays = json.loads(f.read())
|
||||
with pytest.raises(ValueError) as exception_info:
|
||||
statement(invoice, plays)
|
||||
assert "unknown type" in str(exception_info.value)
|
||||
@@ -0,0 +1,6 @@
|
||||
Statement for BigCo
|
||||
Hamlet: $650.00 (55 seats)
|
||||
As You Like It: $580.00 (35 seats)
|
||||
Othello: $500.00 (40 seats)
|
||||
Amount owed is $1,730.00
|
||||
You earned 47 credits
|
||||
Reference in New Issue
Block a user