This project is a Python package named ikea
that simulates a basic inventory system for an IKEA-like furniture store. It is designed to serve as a practical tutorial for Python packaging and testing.
The ikea
package provides:
- A base
Furniture
class withid
andprice
. - Specialized furniture items:
Chair
(withcolor
)Table
(with number ofseats
)Lamp
(with number ofbulbs
andbulb_type
)Plant
(withplant_type
and indoor/outdoor flag)
- A
Store
class to:- Add, remove, and get furniture
- Sell items
- List inventory
Example usage is provided in main.py
.
ikea_project/
├── ikea/ # Main package
│ ├── furniture.py # Base class
│ ├── chair.py # Chair class
│ ├── table.py # Table class
│ ├── lamp.py # Lamp class
│ ├── plant.py # Plant class
│ ├── store.py # Store class
│ └── __init__.py
├── main.py # Example script
├── tests/
| ├── unit_tests/ # Unit tests
| ├── integration_tests/ # Integration tests
│ └── functional_tests/ # Functional tests
├── setup.py
├── requirements.txt # (Optional) dependencies
├── pytest.ini
└── .github/workflows/ # GitHub Actions
To install the package locally in editable mode:
pip install -e .
This allows you to import ikea
while working on the source code directly.
You can run the example script with:
python main.py
It creates a store, adds furniture items, and performs basic operations (list, sell, etc.).
Make sure you have pytest
and pytest-cov
installed:
pip install pytest pytest-cov
pytest
pytest --cov=ikea --cov-report=term
coverage report --fail-under=90
This project includes:
- Unit tests (
unit_tests/
) - Integration tests (
integration_tests/
) - Functional tests (
functional_tests/
)
Use the pytest.ini
to configure which folders to test.
This repository includes GitHub Actions to run tests and check code coverage automatically on push and pull requests to main
.
MIT License (or update if needed)