@theihtisham/dev-pulse 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +43 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +33 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- package/.github/dependabot.yml +16 -0
- package/.github/workflows/ci.yml +33 -0
- package/CODE_OF_CONDUCT.md +27 -0
- package/Dockerfile +8 -0
- package/LICENSE +21 -21
- package/README.md +135 -39
- package/SECURITY.md +22 -0
- package/devpulse/__init__.py +4 -4
- package/devpulse/api/__init__.py +1 -1
- package/devpulse/api/app.py +371 -371
- package/devpulse/cli/__init__.py +1 -1
- package/devpulse/cli/dashboard.py +131 -131
- package/devpulse/cli/main.py +678 -678
- package/devpulse/cli/render.py +175 -175
- package/devpulse/core/__init__.py +34 -34
- package/devpulse/core/analytics.py +487 -487
- package/devpulse/core/config.py +77 -77
- package/devpulse/core/database.py +612 -612
- package/devpulse/core/github_client.py +281 -281
- package/devpulse/core/models.py +142 -142
- package/devpulse/core/report_generator.py +454 -454
- package/devpulse/static/.gitkeep +1 -1
- package/devpulse/templates/report.html +64 -64
- package/package.json +35 -35
- package/pyproject.toml +80 -80
- package/requirements.txt +14 -14
- package/tests/__init__.py +1 -1
- package/tests/conftest.py +208 -208
- package/tests/test_analytics.py +284 -284
- package/tests/test_api.py +313 -313
- package/tests/test_cli.py +204 -204
- package/tests/test_config.py +47 -47
- package/tests/test_database.py +255 -255
- package/tests/test_models.py +107 -107
- package/tests/test_report_generator.py +173 -173
- package/jest.config.js +0 -7
package/tests/conftest.py
CHANGED
|
@@ -1,208 +1,208 @@
|
|
|
1
|
-
"""Shared test fixtures for DevPulse tests."""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import tempfile
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from devpulse.core.database import Database
|
|
8
|
-
from devpulse.core.config import reset_settings
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.fixture(autouse=True)
|
|
12
|
-
def isolated_environment(tmp_path, monkeypatch):
|
|
13
|
-
"""Ensure each test uses an isolated database and config."""
|
|
14
|
-
db_path = str(tmp_path / "test_devpulse.db")
|
|
15
|
-
reports_dir = str(tmp_path / "reports")
|
|
16
|
-
export_dir = str(tmp_path / "exports")
|
|
17
|
-
|
|
18
|
-
monkeypatch.setenv("DEVPULSE_DATABASE_PATH", db_path)
|
|
19
|
-
monkeypatch.setenv("DEVPULSE_REPORTS_DIR", reports_dir)
|
|
20
|
-
monkeypatch.setenv("DEVPULSE_EXPORT_DIR", export_dir)
|
|
21
|
-
monkeypatch.setenv("DEVPULSE_GITHUB_TOKEN", "test_token_12345")
|
|
22
|
-
monkeypatch.setenv("DEVPULSE_GITHUB_USERNAME", "testuser")
|
|
23
|
-
|
|
24
|
-
reset_settings()
|
|
25
|
-
yield
|
|
26
|
-
reset_settings()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@pytest.fixture
|
|
30
|
-
def db(isolated_environment) -> Database:
|
|
31
|
-
"""Provide a fresh database instance."""
|
|
32
|
-
from devpulse.core.config import get_settings
|
|
33
|
-
settings = get_settings()
|
|
34
|
-
return Database(db_path=settings.database_path)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@pytest.fixture
|
|
38
|
-
def sample_commits():
|
|
39
|
-
"""Sample commit data for testing."""
|
|
40
|
-
return [
|
|
41
|
-
{
|
|
42
|
-
"sha": "abc1234567890",
|
|
43
|
-
"repo": "testorg/testrepo",
|
|
44
|
-
"author": "Alice",
|
|
45
|
-
"author_date": "2026-04-01T10:00:00Z",
|
|
46
|
-
"message": "Add new feature",
|
|
47
|
-
"additions": 50,
|
|
48
|
-
"deletions": 10,
|
|
49
|
-
"url": "https://github.com/testorg/testrepo/commit/abc1234567890",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"sha": "def1234567890",
|
|
53
|
-
"repo": "testorg/testrepo",
|
|
54
|
-
"author": "Alice",
|
|
55
|
-
"author_date": "2026-04-01T14:00:00Z",
|
|
56
|
-
"message": "Fix bug in feature",
|
|
57
|
-
"additions": 20,
|
|
58
|
-
"deletions": 5,
|
|
59
|
-
"url": "https://github.com/testorg/testrepo/commit/def1234567890",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"sha": "ghi1234567890",
|
|
63
|
-
"repo": "testorg/testrepo",
|
|
64
|
-
"author": "Bob",
|
|
65
|
-
"author_date": "2026-04-02T09:00:00Z",
|
|
66
|
-
"message": "Update docs",
|
|
67
|
-
"additions": 30,
|
|
68
|
-
"deletions": 0,
|
|
69
|
-
"url": "https://github.com/testorg/testrepo/commit/ghi1234567890",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"sha": "jkl1234567890",
|
|
73
|
-
"repo": "testorg/testrepo",
|
|
74
|
-
"author": "Alice",
|
|
75
|
-
"author_date": "2026-04-03T11:00:00Z",
|
|
76
|
-
"message": "Refactor module",
|
|
77
|
-
"additions": 100,
|
|
78
|
-
"deletions": 80,
|
|
79
|
-
"url": "https://github.com/testorg/testrepo/commit/jkl1234567890",
|
|
80
|
-
},
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@pytest.fixture
|
|
85
|
-
def sample_prs():
|
|
86
|
-
"""Sample pull request data for testing."""
|
|
87
|
-
return [
|
|
88
|
-
{
|
|
89
|
-
"number": 1,
|
|
90
|
-
"repo": "testorg/testrepo",
|
|
91
|
-
"title": "Add new feature",
|
|
92
|
-
"author": "Alice",
|
|
93
|
-
"state": "merged",
|
|
94
|
-
"created_at": "2026-04-01T10:00:00Z",
|
|
95
|
-
"merged_at": "2026-04-02T10:00:00Z",
|
|
96
|
-
"closed_at": "2026-04-02T10:00:00Z",
|
|
97
|
-
"additions": 200,
|
|
98
|
-
"deletions": 50,
|
|
99
|
-
"changed_files": 5,
|
|
100
|
-
"review_comments": 3,
|
|
101
|
-
"url": "https://github.com/testorg/testrepo/pull/1",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"number": 2,
|
|
105
|
-
"repo": "testorg/testrepo",
|
|
106
|
-
"title": "Fix critical bug",
|
|
107
|
-
"author": "Bob",
|
|
108
|
-
"state": "merged",
|
|
109
|
-
"created_at": "2026-04-01T08:00:00Z",
|
|
110
|
-
"merged_at": "2026-04-01T20:00:00Z",
|
|
111
|
-
"closed_at": "2026-04-01T20:00:00Z",
|
|
112
|
-
"additions": 30,
|
|
113
|
-
"deletions": 10,
|
|
114
|
-
"changed_files": 2,
|
|
115
|
-
"review_comments": 5,
|
|
116
|
-
"url": "https://github.com/testorg/testrepo/pull/2",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"number": 3,
|
|
120
|
-
"repo": "testorg/testrepo",
|
|
121
|
-
"title": "WIP: big refactor",
|
|
122
|
-
"author": "Alice",
|
|
123
|
-
"state": "open",
|
|
124
|
-
"created_at": "2026-04-03T09:00:00Z",
|
|
125
|
-
"merged_at": None,
|
|
126
|
-
"closed_at": None,
|
|
127
|
-
"additions": 500,
|
|
128
|
-
"deletions": 300,
|
|
129
|
-
"changed_files": 15,
|
|
130
|
-
"review_comments": 0,
|
|
131
|
-
"url": "https://github.com/testorg/testrepo/pull/3",
|
|
132
|
-
},
|
|
133
|
-
]
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
@pytest.fixture
|
|
137
|
-
def sample_issues():
|
|
138
|
-
"""Sample issue data for testing."""
|
|
139
|
-
return [
|
|
140
|
-
{
|
|
141
|
-
"number": 10,
|
|
142
|
-
"repo": "testorg/testrepo",
|
|
143
|
-
"title": "Bug: crash on startup",
|
|
144
|
-
"author": "Bob",
|
|
145
|
-
"state": "closed",
|
|
146
|
-
"labels": ["bug"],
|
|
147
|
-
"created_at": "2026-03-25T10:00:00Z",
|
|
148
|
-
"closed_at": "2026-04-01T14:00:00Z",
|
|
149
|
-
"url": "https://github.com/testorg/testrepo/issues/10",
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"number": 11,
|
|
153
|
-
"repo": "testorg/testrepo",
|
|
154
|
-
"title": "Feature: add export",
|
|
155
|
-
"author": "Alice",
|
|
156
|
-
"state": "open",
|
|
157
|
-
"labels": ["enhancement"],
|
|
158
|
-
"created_at": "2026-04-02T08:00:00Z",
|
|
159
|
-
"closed_at": None,
|
|
160
|
-
"url": "https://github.com/testorg/testrepo/issues/11",
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"number": 12,
|
|
164
|
-
"repo": "testorg/testrepo",
|
|
165
|
-
"title": "Bug: memory leak",
|
|
166
|
-
"author": "Charlie",
|
|
167
|
-
"state": "open",
|
|
168
|
-
"labels": ["bug", "priority:high"],
|
|
169
|
-
"created_at": "2026-04-03T15:00:00Z",
|
|
170
|
-
"closed_at": None,
|
|
171
|
-
"url": "https://github.com/testorg/testrepo/issues/12",
|
|
172
|
-
},
|
|
173
|
-
]
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@pytest.fixture
|
|
177
|
-
def sample_reviews():
|
|
178
|
-
"""Sample review data for testing."""
|
|
179
|
-
return [
|
|
180
|
-
{
|
|
181
|
-
"id": 100,
|
|
182
|
-
"repo": "testorg/testrepo",
|
|
183
|
-
"pr_number": 1,
|
|
184
|
-
"author": "Bob",
|
|
185
|
-
"state": "APPROVED",
|
|
186
|
-
"submitted_at": "2026-04-01T18:00:00Z",
|
|
187
|
-
"body": "Looks good!",
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"id": 101,
|
|
191
|
-
"repo": "testorg/testrepo",
|
|
192
|
-
"pr_number": 2,
|
|
193
|
-
"author": "Alice",
|
|
194
|
-
"state": "CHANGES_REQUESTED",
|
|
195
|
-
"submitted_at": "2026-04-01T12:00:00Z",
|
|
196
|
-
"body": "Please add tests.",
|
|
197
|
-
},
|
|
198
|
-
]
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
@pytest.fixture
|
|
202
|
-
def populated_db(db, sample_commits, sample_prs, sample_issues, sample_reviews):
|
|
203
|
-
"""Database pre-populated with sample data."""
|
|
204
|
-
db.upsert_commits(sample_commits)
|
|
205
|
-
db.upsert_pull_requests(sample_prs)
|
|
206
|
-
db.upsert_issues(sample_issues)
|
|
207
|
-
db.upsert_reviews(sample_reviews)
|
|
208
|
-
return db
|
|
1
|
+
"""Shared test fixtures for DevPulse tests."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from devpulse.core.database import Database
|
|
8
|
+
from devpulse.core.config import reset_settings
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(autouse=True)
|
|
12
|
+
def isolated_environment(tmp_path, monkeypatch):
|
|
13
|
+
"""Ensure each test uses an isolated database and config."""
|
|
14
|
+
db_path = str(tmp_path / "test_devpulse.db")
|
|
15
|
+
reports_dir = str(tmp_path / "reports")
|
|
16
|
+
export_dir = str(tmp_path / "exports")
|
|
17
|
+
|
|
18
|
+
monkeypatch.setenv("DEVPULSE_DATABASE_PATH", db_path)
|
|
19
|
+
monkeypatch.setenv("DEVPULSE_REPORTS_DIR", reports_dir)
|
|
20
|
+
monkeypatch.setenv("DEVPULSE_EXPORT_DIR", export_dir)
|
|
21
|
+
monkeypatch.setenv("DEVPULSE_GITHUB_TOKEN", "test_token_12345")
|
|
22
|
+
monkeypatch.setenv("DEVPULSE_GITHUB_USERNAME", "testuser")
|
|
23
|
+
|
|
24
|
+
reset_settings()
|
|
25
|
+
yield
|
|
26
|
+
reset_settings()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture
|
|
30
|
+
def db(isolated_environment) -> Database:
|
|
31
|
+
"""Provide a fresh database instance."""
|
|
32
|
+
from devpulse.core.config import get_settings
|
|
33
|
+
settings = get_settings()
|
|
34
|
+
return Database(db_path=settings.database_path)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.fixture
|
|
38
|
+
def sample_commits():
|
|
39
|
+
"""Sample commit data for testing."""
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
"sha": "abc1234567890",
|
|
43
|
+
"repo": "testorg/testrepo",
|
|
44
|
+
"author": "Alice",
|
|
45
|
+
"author_date": "2026-04-01T10:00:00Z",
|
|
46
|
+
"message": "Add new feature",
|
|
47
|
+
"additions": 50,
|
|
48
|
+
"deletions": 10,
|
|
49
|
+
"url": "https://github.com/testorg/testrepo/commit/abc1234567890",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"sha": "def1234567890",
|
|
53
|
+
"repo": "testorg/testrepo",
|
|
54
|
+
"author": "Alice",
|
|
55
|
+
"author_date": "2026-04-01T14:00:00Z",
|
|
56
|
+
"message": "Fix bug in feature",
|
|
57
|
+
"additions": 20,
|
|
58
|
+
"deletions": 5,
|
|
59
|
+
"url": "https://github.com/testorg/testrepo/commit/def1234567890",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"sha": "ghi1234567890",
|
|
63
|
+
"repo": "testorg/testrepo",
|
|
64
|
+
"author": "Bob",
|
|
65
|
+
"author_date": "2026-04-02T09:00:00Z",
|
|
66
|
+
"message": "Update docs",
|
|
67
|
+
"additions": 30,
|
|
68
|
+
"deletions": 0,
|
|
69
|
+
"url": "https://github.com/testorg/testrepo/commit/ghi1234567890",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"sha": "jkl1234567890",
|
|
73
|
+
"repo": "testorg/testrepo",
|
|
74
|
+
"author": "Alice",
|
|
75
|
+
"author_date": "2026-04-03T11:00:00Z",
|
|
76
|
+
"message": "Refactor module",
|
|
77
|
+
"additions": 100,
|
|
78
|
+
"deletions": 80,
|
|
79
|
+
"url": "https://github.com/testorg/testrepo/commit/jkl1234567890",
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@pytest.fixture
|
|
85
|
+
def sample_prs():
|
|
86
|
+
"""Sample pull request data for testing."""
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
"number": 1,
|
|
90
|
+
"repo": "testorg/testrepo",
|
|
91
|
+
"title": "Add new feature",
|
|
92
|
+
"author": "Alice",
|
|
93
|
+
"state": "merged",
|
|
94
|
+
"created_at": "2026-04-01T10:00:00Z",
|
|
95
|
+
"merged_at": "2026-04-02T10:00:00Z",
|
|
96
|
+
"closed_at": "2026-04-02T10:00:00Z",
|
|
97
|
+
"additions": 200,
|
|
98
|
+
"deletions": 50,
|
|
99
|
+
"changed_files": 5,
|
|
100
|
+
"review_comments": 3,
|
|
101
|
+
"url": "https://github.com/testorg/testrepo/pull/1",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"number": 2,
|
|
105
|
+
"repo": "testorg/testrepo",
|
|
106
|
+
"title": "Fix critical bug",
|
|
107
|
+
"author": "Bob",
|
|
108
|
+
"state": "merged",
|
|
109
|
+
"created_at": "2026-04-01T08:00:00Z",
|
|
110
|
+
"merged_at": "2026-04-01T20:00:00Z",
|
|
111
|
+
"closed_at": "2026-04-01T20:00:00Z",
|
|
112
|
+
"additions": 30,
|
|
113
|
+
"deletions": 10,
|
|
114
|
+
"changed_files": 2,
|
|
115
|
+
"review_comments": 5,
|
|
116
|
+
"url": "https://github.com/testorg/testrepo/pull/2",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"number": 3,
|
|
120
|
+
"repo": "testorg/testrepo",
|
|
121
|
+
"title": "WIP: big refactor",
|
|
122
|
+
"author": "Alice",
|
|
123
|
+
"state": "open",
|
|
124
|
+
"created_at": "2026-04-03T09:00:00Z",
|
|
125
|
+
"merged_at": None,
|
|
126
|
+
"closed_at": None,
|
|
127
|
+
"additions": 500,
|
|
128
|
+
"deletions": 300,
|
|
129
|
+
"changed_files": 15,
|
|
130
|
+
"review_comments": 0,
|
|
131
|
+
"url": "https://github.com/testorg/testrepo/pull/3",
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@pytest.fixture
|
|
137
|
+
def sample_issues():
|
|
138
|
+
"""Sample issue data for testing."""
|
|
139
|
+
return [
|
|
140
|
+
{
|
|
141
|
+
"number": 10,
|
|
142
|
+
"repo": "testorg/testrepo",
|
|
143
|
+
"title": "Bug: crash on startup",
|
|
144
|
+
"author": "Bob",
|
|
145
|
+
"state": "closed",
|
|
146
|
+
"labels": ["bug"],
|
|
147
|
+
"created_at": "2026-03-25T10:00:00Z",
|
|
148
|
+
"closed_at": "2026-04-01T14:00:00Z",
|
|
149
|
+
"url": "https://github.com/testorg/testrepo/issues/10",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"number": 11,
|
|
153
|
+
"repo": "testorg/testrepo",
|
|
154
|
+
"title": "Feature: add export",
|
|
155
|
+
"author": "Alice",
|
|
156
|
+
"state": "open",
|
|
157
|
+
"labels": ["enhancement"],
|
|
158
|
+
"created_at": "2026-04-02T08:00:00Z",
|
|
159
|
+
"closed_at": None,
|
|
160
|
+
"url": "https://github.com/testorg/testrepo/issues/11",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"number": 12,
|
|
164
|
+
"repo": "testorg/testrepo",
|
|
165
|
+
"title": "Bug: memory leak",
|
|
166
|
+
"author": "Charlie",
|
|
167
|
+
"state": "open",
|
|
168
|
+
"labels": ["bug", "priority:high"],
|
|
169
|
+
"created_at": "2026-04-03T15:00:00Z",
|
|
170
|
+
"closed_at": None,
|
|
171
|
+
"url": "https://github.com/testorg/testrepo/issues/12",
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@pytest.fixture
|
|
177
|
+
def sample_reviews():
|
|
178
|
+
"""Sample review data for testing."""
|
|
179
|
+
return [
|
|
180
|
+
{
|
|
181
|
+
"id": 100,
|
|
182
|
+
"repo": "testorg/testrepo",
|
|
183
|
+
"pr_number": 1,
|
|
184
|
+
"author": "Bob",
|
|
185
|
+
"state": "APPROVED",
|
|
186
|
+
"submitted_at": "2026-04-01T18:00:00Z",
|
|
187
|
+
"body": "Looks good!",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": 101,
|
|
191
|
+
"repo": "testorg/testrepo",
|
|
192
|
+
"pr_number": 2,
|
|
193
|
+
"author": "Alice",
|
|
194
|
+
"state": "CHANGES_REQUESTED",
|
|
195
|
+
"submitted_at": "2026-04-01T12:00:00Z",
|
|
196
|
+
"body": "Please add tests.",
|
|
197
|
+
},
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@pytest.fixture
|
|
202
|
+
def populated_db(db, sample_commits, sample_prs, sample_issues, sample_reviews):
|
|
203
|
+
"""Database pre-populated with sample data."""
|
|
204
|
+
db.upsert_commits(sample_commits)
|
|
205
|
+
db.upsert_pull_requests(sample_prs)
|
|
206
|
+
db.upsert_issues(sample_issues)
|
|
207
|
+
db.upsert_reviews(sample_reviews)
|
|
208
|
+
return db
|