Add Pretty Table project: plan, accepted documents and code
Business Case, Stakeholder Analysis, Project Plan and milestone MIL-001 with review records RC-001 to RC-003, then the Python project: PrettyTable Pokemon table, constants, pytest tests, pyproject.toml, Doxyfile, CI workflow and README. Task: MIL-001#1 Task: MIL-001#2 Task: MIL-001#3 Task: MIL-001#4 Task: MIL-001#5 Task: MIL-001#6 Task: MIL-001#7 Task: MIL-001#8
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Tests for the Pokemon table."""
|
||||
|
||||
import pytest
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from pretty_table.constants import COLUMN_TITLES, POKEMON
|
||||
from pretty_table.main import create_table, main
|
||||
|
||||
EXPECTED_TABLE = """\
|
||||
+--------------+----------+
|
||||
| Pokemon Name | Type |
|
||||
+--------------+----------+
|
||||
| Pikachu | Electric |
|
||||
| Squirtle | Water |
|
||||
| Charmander | Fire |
|
||||
+--------------+----------+
|
||||
"""
|
||||
|
||||
|
||||
def test_create_table_returns_prettytable() -> None:
|
||||
assert isinstance(create_table(), PrettyTable)
|
||||
|
||||
|
||||
def test_create_table_has_the_column_titles() -> None:
|
||||
assert tuple(create_table().field_names) == COLUMN_TITLES
|
||||
|
||||
|
||||
def test_create_table_has_one_row_per_pokemon() -> None:
|
||||
table = create_table()
|
||||
assert len(table.rows) == len(POKEMON)
|
||||
assert [tuple(row) for row in table.rows] == list(POKEMON)
|
||||
|
||||
|
||||
def test_create_table_renders_the_expected_text() -> None:
|
||||
assert create_table().get_string() == EXPECTED_TABLE.rstrip("\n")
|
||||
|
||||
|
||||
def test_main_prints_the_table(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
main()
|
||||
assert capsys.readouterr().out == EXPECTED_TABLE
|
||||
Reference in New Issue
Block a user