Skip to content

Commit 19bc697

Browse files
committed
todo: rename some json props to match other json layouts
1 parent ad1d8d6 commit 19bc697

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

test/test_todo.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def test_todo_json_success(db, client):
5050
assert data['groups']['unknown']
5151
assert data['groups']['bumped']
5252

53-
assert data['issues']['orphan_issues']
54-
assert data['issues']['unknown_issues']
53+
assert data['issues']['orphan']
54+
assert data['issues']['unknown']
5555

5656

5757
def test_todo_json_empty(db, client):
@@ -66,8 +66,8 @@ def test_todo_json_empty(db, client):
6666
assert not data['groups']['unknown']
6767
assert not data['groups']['bumped']
6868

69-
assert not data['issues']['orphan_issues']
70-
assert not data['issues']['unknown_issues']
69+
assert not data['issues']['orphan']
70+
assert not data['issues']['unknown']
7171

7272

7373
@create_issue(id='CVE-1111-1111', issue_type=issue_types[2])
@@ -172,7 +172,7 @@ def test_todo_group_bumped(db, client):
172172
group = next(iter(data['groups']['bumped']))
173173
assert DEFAULT_GROUP_NAME == group['name']
174174
assert ['foo'] == group['packages']
175-
assert '1.2.3-4' in group['current'].values()
175+
assert '1.2.3-4' in next(iter(group['versions']))['version']
176176

177177

178178
@create_issue(id='CVE-1111-1111', issue_type=issue_types[1])
@@ -192,9 +192,9 @@ def test_todo_issues_orphan(db, client):
192192
assert 200 == resp.status_code
193193

194194
data = resp.get_json()
195-
assert 1 == len(data['issues']['orphan_issues'])
195+
assert 1 == len(data['issues']['orphan'])
196196

197-
issue = next(iter(data['issues']['orphan_issues']))
197+
issue = next(iter(data['issues']['orphan']))
198198
assert 'CVE-1111-1111' == issue['name']
199199

200200

@@ -206,7 +206,7 @@ def test_todo_issues_referenced_not_orphan(db, client):
206206
assert 200 == resp.status_code
207207

208208
data = resp.get_json()
209-
assert not data['issues']['orphan_issues']
209+
assert not data['issues']['orphan']
210210

211211

212212
@create_issue(id='CVE-1111-1111', issue_type=issue_types[2], remote=Remote.remote, severity=Severity.low, description='yay')
@@ -215,7 +215,7 @@ def test_todo_issues_not_unknown_with_data(db, client):
215215
assert 200 == resp.status_code
216216

217217
data = resp.get_json()
218-
assert not data['issues']['unknown_issues']
218+
assert not data['issues']['unknown']
219219

220220

221221
@create_issue(id='CVE-1111-1111', issue_type=issue_types[0], remote=Remote.remote, severity=Severity.low, description='yay')
@@ -224,9 +224,9 @@ def test_todo_issues_unknown_without_type(db, client):
224224
assert 200 == resp.status_code
225225

226226
data = resp.get_json()
227-
assert 1 == len(data['issues']['unknown_issues'])
227+
assert 1 == len(data['issues']['unknown'])
228228

229-
issue = next(iter(data['issues']['unknown_issues']))
229+
issue = next(iter(data['issues']['unknown']))
230230
assert 'CVE-1111-1111' == issue['name']
231231

232232

@@ -236,9 +236,9 @@ def test_todo_issues_unknown_without_remote(db, client):
236236
assert 200 == resp.status_code
237237

238238
data = resp.get_json()
239-
assert 1 == len(data['issues']['unknown_issues'])
239+
assert 1 == len(data['issues']['unknown'])
240240

241-
issue = next(iter(data['issues']['unknown_issues']))
241+
issue = next(iter(data['issues']['unknown']))
242242
assert 'CVE-1111-1111' == issue['name']
243243

244244

@@ -248,9 +248,9 @@ def test_todo_issues_unknown_without_severity(db, client):
248248
assert 200 == resp.status_code
249249

250250
data = resp.get_json()
251-
assert 1 == len(data['issues']['unknown_issues'])
251+
assert 1 == len(data['issues']['unknown'])
252252

253-
issue = next(iter(data['issues']['unknown_issues']))
253+
issue = next(iter(data['issues']['unknown']))
254254
assert 'CVE-1111-1111' == issue['name']
255255

256256

@@ -260,7 +260,7 @@ def test_todo_issues_unknown_without_description(db, client):
260260
assert 200 == resp.status_code
261261

262262
data = resp.get_json()
263-
assert 1 == len(data['issues']['unknown_issues'])
263+
assert 1 == len(data['issues']['unknown'])
264264

265-
issue = next(iter(data['issues']['unknown_issues']))
265+
issue = next(iter(data['issues']['unknown']))
266266
assert 'CVE-1111-1111' == issue['name']

tracker/view/todo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def advisory_json(data):
143143
entry = OrderedDict()
144144
entry['name'] = advisory.id
145145
entry['date'] = advisory.created.strftime('%Y-%m-%d')
146-
entry['severity'] = advisory.group_package.group.severity.label
147146
entry['type'] = advisory.advisory_type
148-
entry['fixed'] = group.fixed
147+
entry['severity'] = advisory.group_package.group.severity.label
149148
entry['affected'] = group.affected
149+
entry['fixed'] = group.fixed
150150
entry['package'] = package.pkgname
151151
return entry
152152

@@ -169,18 +169,18 @@ def bumped_groups_json(item):
169169
entry['status'] = group.status.label
170170
entry['severity'] = group.severity.label
171171
entry['affected'] = group.affected
172-
entry['current'] = dict((pkg.database, pkg.version) for pkg in versions)
172+
entry['versions'] = [{'version': pkg.version, 'database': pkg.database} for pkg in versions]
173173
entry['packages'] = list(pkgnames)
174174
return entry
175175

176176

177177
def cve_json(cve):
178178
entry = OrderedDict()
179-
entry['description'] = cve.description
180179
entry['name'] = cve.id
181-
entry['label'] = cve.severity.label
182-
entry['remote'] = cve.remote.name
183180
entry['type'] = cve.issue_type
181+
entry['severity'] = cve.severity.label
182+
entry['vector'] = cve.remote.label
183+
entry['description'] = cve.description
184184
return entry
185185

186186

@@ -202,8 +202,8 @@ def todo_json(postfix=None):
202202
}
203203

204204
json_data['issues'] = {
205-
'orphan_issues': [cve_json(cve) for cve in data['orphan_issues']],
206-
'unknown_issues': [cve_json(cve) for cve in data['unknown_issues']]
205+
'orphan': [cve_json(cve) for cve in data['orphan_issues']],
206+
'unknown': [cve_json(cve) for cve in data['unknown_issues']]
207207
}
208208

209209
return json_data

0 commit comments

Comments
 (0)