Skip to content

Commit 99709a0

Browse files
committed
test: add unit tests for sysinfo
1 parent 1d186b4 commit 99709a0

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

src/sysinfo_cli.egg-info/PKG-INFO

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,131 @@ Provides-Extra: dev
88
Requires-Dist: ruff; extra == "dev"
99
Requires-Dist: black; extra == "dev"
1010
Requires-Dist: pytest; extra == "dev"
11+
12+
# 🖥️ sysinfo-cli
13+
14+
A simple command-line tool written in pure **Python** that displays system information such as **CPU**, **RAM**, **disk**, **network**, and **uptime**.
15+
It supports both standard text and JSON output.
16+
17+
---
18+
19+
## 🚀 Quick Start (Local)
20+
21+
```bash
22+
# Clone this repository
23+
git clone https://github.com/mircothibes/sysinfo-cli.git
24+
cd sysinfo-cli
25+
26+
# Create and activate the virtual environment
27+
python -m venv .venv && source .venv/bin/activate
28+
29+
# Install dependencies (development tools included)
30+
pip install -e ".[dev]"
31+
32+
# Run the CLI
33+
python -m sysinfo.cli
34+
python -m sysinfo.cli --json
35+
```
36+
37+
Example output:
38+
```bash
39+
CPU: cores=16 load={'1m': 0.18, '5m': 0.11, '15m': 0.03}
40+
RAM: used=640000kB/8036544kB (7.9%)
41+
DISK: used=3458965504/1081101176832 (0.32%)
42+
NET: total_rx=290 total_tx=42
43+
UPTIME: 21000s
44+
```
45+
---
46+
47+
## 🐳 Docker
48+
49+
You can run the same CLI in a lightweight Docker container.
50+
```bash
51+
# Build the image
52+
docker build -t mvtk/sysinfo-cli:0.1.0 .
53+
54+
# Run it (JSON output)
55+
docker run --rm mvtk/sysinfo-cli:0.1.0 --json
56+
57+
# Or plain text output
58+
docker run --rm mvtk/sysinfo-cli:0.1.0
59+
```
60+
61+
Example JSON output:
62+
```bash
63+
{
64+
"cpu": {"cores": 16, "loadavg": {"1m": 0.18, "5m": 0.11, "15m": 0.03}},
65+
"ram": {"total_kb": 8036544, "available_kb": 7397756, "used_kb": 638788, "percent": 7.95},
66+
"disk": {"path": "/", "total_bytes": 1081101176832, "used_bytes": 3458957312, "free_bytes": 1022649864192, "percent": 0.32},
67+
"net": {"total": {"rx_bytes": 290, "tx_bytes": 42}},
68+
"uptime": {"seconds": 20201}
69+
}
70+
```
71+
72+
---
73+
74+
## 🧰 Development
75+
76+
I use Neovim as my main development environment with:
77+
- lazy.nvim
78+
- mason.nvim
79+
- nvim-lspconfig -> (Pyright)
80+
- conform.nvim -> for formatting
81+
82+
Useful Commands:
83+
```bash
84+
ruff check .
85+
black .
86+
pytest -q
87+
```
88+
89+
---
90+
91+
## 🧪 Tests
92+
93+
Run all tests using pytest:
94+
```bash
95+
pytest -q
96+
```
97+
98+
---
99+
100+
## 📦 Project Structure
101+
```bash
102+
sysinfo-cli/
103+
├── src/
104+
│ └── sysinfo/
105+
│ ├── __init__.py
106+
│ └── cli.py
107+
├── tests/
108+
│ └── test_cli.py
109+
├── pyproject.toml
110+
├── Dockerfile
111+
├── .dockerignore
112+
├── .gitignore
113+
└── README.md
114+
```
115+
116+
---
117+
118+
## ⚙️C ommand Reference
119+
120+
| Command | Description |
121+
| ----------- | -------------------------- |
122+
| `--json` | Output data in JSON format |
123+
| `--version` | Display CLI version |
124+
| `--help` | Show help message |
125+
126+
---
127+
128+
## 🧾 License
129+
130+
This project is released under the MIT License.
131+
132+
---
133+
134+
## 👨‍💻 Author
135+
136+
Marcos Vinicius Thibes Kemer
137+
138+
---

tests/test_text_mode.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess
2+
import sys
3+
4+
5+
def test_text_mode_runs():
6+
out = subprocess.check_output([sys.executable, "-m", "sysinfo.cli"])
7+
s = out.decode().lower()
8+
assert "cpu:" in s
9+
assert "ram:" in s
10+
assert "disk:" in s
11+
assert "net:" in s
12+
assert "uptime:" in s
13+

0 commit comments

Comments
 (0)