Skip to content

Commit

Permalink
todo: rename some json props to match other json layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
anthraxx committed May 30, 2018
1 parent ad1d8d6 commit 19bc697
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
34 changes: 17 additions & 17 deletions test/test_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_todo_json_success(db, client):
assert data['groups']['unknown']
assert data['groups']['bumped']

assert data['issues']['orphan_issues']
assert data['issues']['unknown_issues']
assert data['issues']['orphan']
assert data['issues']['unknown']


def test_todo_json_empty(db, client):
Expand All @@ -66,8 +66,8 @@ def test_todo_json_empty(db, client):
assert not data['groups']['unknown']
assert not data['groups']['bumped']

assert not data['issues']['orphan_issues']
assert not data['issues']['unknown_issues']
assert not data['issues']['orphan']
assert not data['issues']['unknown']


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


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

data = resp.get_json()
assert 1 == len(data['issues']['orphan_issues'])
assert 1 == len(data['issues']['orphan'])

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


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

data = resp.get_json()
assert not data['issues']['orphan_issues']
assert not data['issues']['orphan']


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

data = resp.get_json()
assert not data['issues']['unknown_issues']
assert not data['issues']['unknown']


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

data = resp.get_json()
assert 1 == len(data['issues']['unknown_issues'])
assert 1 == len(data['issues']['unknown'])

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


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

data = resp.get_json()
assert 1 == len(data['issues']['unknown_issues'])
assert 1 == len(data['issues']['unknown'])

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


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

data = resp.get_json()
assert 1 == len(data['issues']['unknown_issues'])
assert 1 == len(data['issues']['unknown'])

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


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

data = resp.get_json()
assert 1 == len(data['issues']['unknown_issues'])
assert 1 == len(data['issues']['unknown'])

issue = next(iter(data['issues']['unknown_issues']))
issue = next(iter(data['issues']['unknown']))
assert 'CVE-1111-1111' == issue['name']
16 changes: 8 additions & 8 deletions tracker/view/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def advisory_json(data):
entry = OrderedDict()
entry['name'] = advisory.id
entry['date'] = advisory.created.strftime('%Y-%m-%d')
entry['severity'] = advisory.group_package.group.severity.label
entry['type'] = advisory.advisory_type
entry['fixed'] = group.fixed
entry['severity'] = advisory.group_package.group.severity.label
entry['affected'] = group.affected
entry['fixed'] = group.fixed
entry['package'] = package.pkgname
return entry

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


def cve_json(cve):
entry = OrderedDict()
entry['description'] = cve.description
entry['name'] = cve.id
entry['label'] = cve.severity.label
entry['remote'] = cve.remote.name
entry['type'] = cve.issue_type
entry['severity'] = cve.severity.label
entry['vector'] = cve.remote.label
entry['description'] = cve.description
return entry


Expand All @@ -202,8 +202,8 @@ def todo_json(postfix=None):
}

json_data['issues'] = {
'orphan_issues': [cve_json(cve) for cve in data['orphan_issues']],
'unknown_issues': [cve_json(cve) for cve in data['unknown_issues']]
'orphan': [cve_json(cve) for cve in data['orphan_issues']],
'unknown': [cve_json(cve) for cve in data['unknown_issues']]
}

return json_data

0 comments on commit 19bc697

Please sign in to comment.