-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from sarah256/recent-stories
Add API endpoint for recent stories
- Loading branch information
Showing
2 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# SPDX-License-Identifier: GPL-3.0+ | ||
|
||
from __future__ import unicode_literals | ||
import json | ||
from datetime import datetime | ||
|
||
from estuary.models.koji import KojiBuild | ||
from estuary.models.bugzilla import BugzillaBug | ||
from estuary.models.distgit import DistGitCommit | ||
from estuary.models.errata import Advisory | ||
from estuary.models.freshmaker import FreshmakerEvent | ||
|
||
|
||
def test_get_recent_nodes(client): | ||
"""Test the get_recent_nodes function.""" | ||
expected = { | ||
'data': { | ||
'Advisory': [ | ||
{ | ||
'advisory_name': None, | ||
'update_date': '2017-05-30T11:44:38+00:00', | ||
'issue_date': None, | ||
'created_at': None, | ||
'state': None, | ||
'product_short_name': None, | ||
'product_name': None, | ||
'content_types': None, | ||
'security_sla': None, | ||
'synopsis': None, | ||
'security_impact': None, | ||
'status_time': None, | ||
'actual_ship_date': None, | ||
'release_date': None, | ||
'id': '66666' | ||
} | ||
], | ||
'DistGitCommit': [ | ||
{ | ||
'log_message': None, | ||
'author_date': None, | ||
'hash': '55555', | ||
'commit_date': '2017-05-02T11:44:38+00:00' | ||
} | ||
], | ||
'FreshmakerEvent': [ | ||
{ | ||
'state_reason': None, | ||
'state_name': None, | ||
'id': '77777', | ||
'state': None, | ||
'event_type_id': None, | ||
'message_id': None | ||
} | ||
], | ||
'KojiBuild': [ | ||
{ | ||
'name': None, | ||
'extra': None, | ||
'start_time': None, | ||
'creation_time': None, | ||
'state': None, | ||
'completion_time': '2017-05-27T11:44:38+00:00', | ||
'epoch': None, | ||
'version': None, | ||
'release': None, | ||
'id': '44444' | ||
} | ||
], | ||
'BugzillaBug': [ | ||
{ | ||
'status': None, | ||
'votes': None, | ||
'severity': None, | ||
'classification': None, | ||
'resolution': None, | ||
'product_version': None, | ||
'creation_time': None, | ||
'modified_time': '2017-06-26T11:44:38+00:00', | ||
'product_name': None, | ||
'priority': None, | ||
'short_description': None, | ||
'target_milestone': None, | ||
'id': '22222' | ||
}, | ||
{ | ||
'status': None, | ||
'votes': None, | ||
'severity': None, | ||
'classification': None, | ||
'resolution': None, | ||
'product_version': None, | ||
'creation_time': None, | ||
'modified_time': '2017-05-26T11:44:38+00:00', | ||
'product_name': None, | ||
'priority': None, | ||
'short_description': None, | ||
'target_milestone': None, | ||
'id': '33333' | ||
}, | ||
{ | ||
'status': None, | ||
'votes': None, | ||
'severity': None, | ||
'classification': None, | ||
'resolution': None, | ||
'product_version': None, | ||
'creation_time': None, | ||
'modified_time': '2017-04-26T11:44:38+00:00', | ||
'product_name': None, | ||
'priority': None, | ||
'short_description': None, | ||
'target_milestone': None, | ||
'id': '11111' | ||
} | ||
] | ||
}, | ||
'metadata': {} | ||
} | ||
|
||
BugzillaBug.get_or_create({ | ||
'id_': '11111', | ||
'modified_time': datetime(2017, 4, 26, 11, 44, 38) | ||
}) | ||
BugzillaBug.get_or_create({ | ||
'id_': '22222', | ||
'modified_time': datetime(2017, 6, 26, 11, 44, 38) | ||
}) | ||
BugzillaBug.get_or_create({ | ||
'id_': '33333', | ||
'modified_time': datetime(2017, 5, 26, 11, 44, 38) | ||
}) | ||
KojiBuild.get_or_create({ | ||
'id_': '44444', | ||
'completion_time': datetime(2017, 5, 27, 11, 44, 38) | ||
}) | ||
DistGitCommit.get_or_create({ | ||
'hash_': '55555', | ||
'commit_date': datetime(2017, 5, 2, 11, 44, 38) | ||
}) | ||
Advisory.get_or_create({ | ||
'id_': '66666', | ||
'update_date': datetime(2017, 5, 30, 11, 44, 38) | ||
}) | ||
FreshmakerEvent.get_or_create({ | ||
'id_': '77777' | ||
}) | ||
|
||
rv = client.get('/api/v1/recents') | ||
assert rv.status_code == 200 | ||
assert json.loads(rv.data.decode('utf-8')) == expected |