Test & implement #42

This commit is contained in:
Jeff Forcier 2015-11-05 13:20:54 -08:00
parent 4f9bb7a81f
commit 6aaf9ef1ab
2 changed files with 28 additions and 0 deletions

View file

@ -163,6 +163,16 @@ def append_unreleased_entries(app, lines, releases):
})
def reorder_release_entries(releases):
"""
Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc.
"""
order = {'feature': 0, 'bug': 1, 'support': 2}
for release in releases:
entries = release['entries'][:]
release['entries'] = sorted(entries, key=lambda x: order[x.type])
def construct_entry_with_release(focus, issues, lines, log, releases, rest):
"""
Releases 'eat' the entries in their line's list and get added to the
@ -372,6 +382,8 @@ def construct_releases(entries, app):
append_unreleased_entries(app, lines, releases)
reorder_release_entries(releases)
return releases

View file

@ -332,6 +332,22 @@ class releases(Spec):
cl = _changelog2dict(cl)
assert len(cl['1.0.1']) == 2
def issues_are_sorted_by_type_within_releases(self):
b1 = _issue('bug', '123', major=True)
b2 = _issue('bug', '124', major=True)
s1 = _issue('support', '25')
s2 = _issue('support', '26')
f1 = _issue('feature', '3455')
f2 = _issue('feature', '3456')
# Semi random definitely-not-in-desired-order order
changelog = _changelog2dict(_releases('1.1', b1, s1, s2, f1, b2, f2))
# Order should be feature, bug, support. While it doesn't REALLY
# matter, assert that within each category the order matches the old
# 'reverse chronological' order.
eq_(changelog['1.1'], [f2, f1, b2, b1, s2, s1])
def _obj2name(obj):
cls = obj if isinstance(obj, type) else obj.__class__