Skip to content

Commit

Permalink
test: Add package related test file
Browse files Browse the repository at this point in the history
Add a new file for tests related to packages and test the package json
feed in it's basic form.
  • Loading branch information
jelly authored and anthraxx committed May 22, 2018
1 parent 9165ce0 commit 5cf8869
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
5 changes: 2 additions & 3 deletions test/test_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from flask import url_for
from werkzeug.exceptions import Forbidden
from werkzeug.exceptions import NotFound
Expand Down Expand Up @@ -314,8 +312,9 @@ def test_forbid_delete_with_advisory(db, client):
def test_show_group_json(db, client):
resp = client.get(url_for('tracker.show_group_json', avg=DEFAULT_GROUP_NAME, postfix='/json'), follow_redirects=True)
assert 200 == resp.status_code
data = json.loads(resp.data.decode())
data = resp.get_json()
assert data['name'] == DEFAULT_GROUP_NAME
assert data['issues'] == [DEFAULT_ISSUE_ID]
assert data['packages'] == ['foo']
assert data['affected'] == '1.2.3-3'
assert data['fixed'] == '1.2.3-4'
Expand Down
30 changes: 30 additions & 0 deletions test/test_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import url_for
from werkzeug.exceptions import NotFound

from tracker.model.cve import issue_types
from tracker.model.enum import Publication

from .conftest import DEFAULT_ADVISORY_ID
from .conftest import DEFAULT_GROUP_ID
from .conftest import create_advisory
from .conftest import create_group
from .conftest import create_package


@create_package(name='foo', version='1.2.3-4')
@create_group(id=DEFAULT_GROUP_ID, packages=['foo'], affected='1.2.3-3', fixed='1.2.3-4')
@create_advisory(id=DEFAULT_ADVISORY_ID, group_package_id=DEFAULT_GROUP_ID, advisory_type=issue_types[1], reference='https://security.archlinux.org', publication=Publication.published)
def test_show_package_json(db, client):
resp = client.get(url_for('tracker.show_package_json', pkgname='foo', suffix='/json'), follow_redirects=True)
assert 200 == resp.status_code
data = resp.get_json()
assert len(data['groups']) == 1
assert len(data['versions']) == 1
assert len(data['advisories']) == 1
assert len(data['issues']) == 1
assert data['name'] == 'foo'


def test_show_package_json_not_found(db, client):
resp = client.get(url_for('tracker.show_package_json', pkgname='foo', suffix='/json'), follow_redirects=True)
assert NotFound.code == resp.status_code

0 comments on commit 5cf8869

Please sign in to comment.