-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ef8181d
Showing
6 changed files
with
4,079 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Python Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: pip install pytest | ||
- name: Run tests | ||
run: pytest test_smart_device.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Python | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.so | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# Virtual Environment | ||
venv/ | ||
env/ | ||
ENV/ | ||
|
||
# IDE specific files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
.DS_Store | ||
|
||
# Test coverage | ||
.coverage | ||
htmlcov/ | ||
.tox/ | ||
.pytest_cache/ | ||
|
||
# Logs | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Smart Device Controller 🎮 | ||
|
||
A Python implementation of a smart device controller created as part of the EPAI (Extensive Python AI) course. This project demonstrates advanced Python concepts including class attributes, callable classes, and function attributes. | ||
|
||
## 🌟 Features | ||
|
||
- Class-based smart device implementation | ||
- Device status management and tracking | ||
- Built-in device counter | ||
- Callable class functionality | ||
- Function attributes for device information | ||
- Comprehensive test coverage | ||
|
||
## 🧩 Class Structure | ||
|
||
### SmartDevice Class | ||
The main class that implements smart device functionality: | ||
|
||
```python | ||
device = SmartDevice(device_name="Living Room Light", model_number="LRL001", is_online=False) | ||
``` | ||
|
||
#### Key Components: | ||
|
||
1. **Class Attributes** | ||
- `device_count`: Tracks total number of devices created | ||
|
||
2. **Instance Attributes** | ||
- `device_name`: Name of the device | ||
- `model_number`: Device model number | ||
- `is_online`: Device online status | ||
- `status`: Dictionary storing device status attributes | ||
|
||
3. **Methods** | ||
- `update_status(attribute, value)`: Update device status | ||
- `get_status(attribute)`: Retrieve status attributes | ||
- `toggle_online()`: Toggle device online state | ||
- `reset()`: Reset device to default state | ||
|
||
4. **Special Features** | ||
- Callable class implementation | ||
- `device_info` function attribute | ||
|
||
## 🚀 Usage Examples | ||
|
||
```python | ||
# Create a new device | ||
device = SmartDevice("Kitchen Light", "KL100") | ||
|
||
# Update device status | ||
device.update_status("battery", 85) | ||
device.update_status("temperature", 24.5) | ||
|
||
# Get specific status | ||
battery_level = device.get_status("battery") # Returns 85 | ||
|
||
# Toggle device online status | ||
device.toggle_online() | ||
|
||
# Use callable instance | ||
print(device()) # Prints formatted device name and model | ||
|
||
# Get device info using function attribute | ||
info = device.device_info() | ||
``` | ||
|
||
## 🧪 Testing | ||
|
||
The project includes comprehensive tests in `test_smart_device.py`. Run tests using: | ||
|
||
```bash | ||
pytest test_smart_device.py | ||
``` | ||
|
||
## 🎓 Educational Context | ||
|
||
This project is part of the EPAI course curriculum, demonstrating: | ||
- Object-Oriented Programming in Python | ||
- Class and Instance Attributes | ||
- Special Methods (`__init__`, `__call__`) | ||
- Function Attributes | ||
- Property Decorators | ||
- Test-Driven Development | ||
|
||
## 📝 Requirements | ||
|
||
- Python 3.6+ | ||
- pytest (for running tests) | ||
|
Oops, something went wrong.