| |
@@ -1,11 +1,11 @@
|
| |
import datetime
|
| |
+ import re
|
| |
|
| |
from blockerbugs.models.milestone import Milestone
|
| |
from blockerbugs.models.release import Release
|
| |
from blockerbugs.models.bug import Bug
|
| |
from blockerbugs.models.update import Update
|
| |
- from blockerbugs import db
|
| |
- from blockerbugs import app
|
| |
+ from blockerbugs import app, db
|
| |
from blockerbugs.controllers import main
|
| |
|
| |
|
| |
@@ -26,21 +26,32 @@
|
| |
|
| |
|
| |
def add_bug(bugid, summary, milestone):
|
| |
- test_bug = Bug(bugid,
|
| |
- 'https://bugzilla.redhat.com/show_bug.cgi?id=%d' % bugid,
|
| |
- summary, 'NEW', 'testcomponent', milestone, True, True, 'John Doe')
|
| |
+ test_bug = Bug(bugid=bugid,
|
| |
+ url='https://bugzilla.redhat.com/show_bug.cgi?id=%d' % bugid,
|
| |
+ summary=summary,
|
| |
+ status='NEW',
|
| |
+ component='testcomponent',
|
| |
+ milestone=milestone,
|
| |
+ active=True,
|
| |
+ needinfo=True,
|
| |
+ needinfo_requestee='John Doe')
|
| |
test_bug.accepted_blocker = True
|
| |
db.session.add(test_bug)
|
| |
db.session.commit()
|
| |
return test_bug
|
| |
|
| |
|
| |
- def add_update(title, status, bugs, release, milestones,
|
| |
- url='http://localhost/update'):
|
| |
- test_update = Update(title, url, 1, status, bugs,
|
| |
- release, milestones,
|
| |
- date_submitted=datetime.datetime.utcnow())
|
| |
- test_update.stable_karma = 3
|
| |
+ def add_update(updateid, release, status, bugs=[]):
|
| |
+ test_update = Update(updateid=updateid,
|
| |
+ release=release,
|
| |
+ status=status,
|
| |
+ karma=1,
|
| |
+ url='http://localhost/update',
|
| |
+ date_submitted=datetime.datetime.utcnow(),
|
| |
+ request=None,
|
| |
+ title=None,
|
| |
+ stable_karma=3,
|
| |
+ bugs=bugs)
|
| |
db.session.add(test_update)
|
| |
db.session.commit()
|
| |
return test_update
|
| |
@@ -211,93 +222,82 @@
|
| |
|
| |
class TestGetFunctions(object):
|
| |
@classmethod
|
| |
- def setup_class(cls):
|
| |
+ def setup_method(self):
|
| |
+ self.client = app.test_client()
|
| |
db.session.rollback()
|
| |
db.drop_all()
|
| |
db.create_all()
|
| |
- cls.release = add_release(99)
|
| |
- cls.milestone = add_milestone(cls.release, 'beta', 100, 101,
|
| |
- '99-beta', True)
|
| |
- bug1 = add_bug(9000, 'testbug1', cls.milestone)
|
| |
- bug1.depends_on = [9090]
|
| |
- bug2 = add_bug(9001, 'testbug2', cls.milestone)
|
| |
- bug2.accepted_blocker = False
|
| |
+ self.release = add_release(99)
|
| |
+ self.milestone = add_milestone(self.release, 'beta', 100, 101, '99-beta', True)
|
| |
+ self.bug1 = add_bug(9000, 'testbug1', self.milestone)
|
| |
+ self.bug1.depends_on = [9090]
|
| |
+ self.bug2 = add_bug(9001, 'testbug2', self.milestone)
|
| |
+ self.bug2.accepted_blocker = False
|
| |
# a bug that fixes a Final blocker
|
| |
- cls.finalmile = add_milestone(cls.release, 'final', 200, 201, '99-final')
|
| |
- finalbug = add_bug(9002, 'finalbug', cls.finalmile)
|
| |
+ self.finalmile = add_milestone(self.release, 'final', 200, 201, '99-final')
|
| |
+ self.finalbug = add_bug(9002, 'finalbug', self.finalmile)
|
| |
# we add finalbug to this update for requests.txt testing:
|
| |
- # it should *not* show in the generated request, the update
|
| |
+ # it should *not* show in the generated request for Beta, the update
|
| |
# will be in the request but it should only list bug1, not
|
| |
# finalbug, as bug1 is for Beta and finalbug for Final
|
| |
- cls.update_pending_stable = add_update(u'test-pending-stable.fc99', u'stable',
|
| |
- [bug1, finalbug], cls.release, [cls.milestone])
|
| |
- cls.update_pending_stable.pending = True
|
| |
- cls.update_pending_stable.request = 'stable'
|
| |
- cls.update_stable1 = add_update(u'test-stable1.fc99', u'stable', [bug1],
|
| |
- cls.release, [cls.milestone])
|
| |
- cls.update_stable2 = add_update(u'test-stable2.fc99', u'stable', [bug2],
|
| |
- cls.release, [cls.milestone])
|
| |
- cls.update_pending_testing = add_update(u'test-pending-testing.fc99', u'testing', [bug1],
|
| |
- cls.release, [cls.milestone])
|
| |
- cls.update_pending_testing.pending = True
|
| |
- cls.update_testing1 = add_update(u'test-testing1.fc99', u'testing', [bug1],
|
| |
- cls.release, [cls.milestone])
|
| |
- cls.update_testing2 = add_update(u'test-testing2.fc99', u'testing', [bug2],
|
| |
- cls.release, [cls.milestone])
|
| |
+ self.update_pending_stable = add_update('test-pending-stable.fc99', self.release, 'testing',
|
| |
+ [self.bug1, self.finalbug])
|
| |
+ self.update_pending_stable.request = 'stable'
|
| |
+ self.update_stable1 = add_update('test-stable1.fc99', self.release, 'stable', [self.bug1])
|
| |
+ self.update_stable2 = add_update('test-stable2.fc99', self.release, 'stable', [self.bug2])
|
| |
+ self.update_pending_testing = add_update('test-pending-testing.fc99', self.release,
|
| |
+ 'pending', [self.bug1])
|
| |
+ self.update_pending_testing.request = 'testing'
|
| |
+ self.update_testing1 = add_update('test-testing1.fc99', self.release, 'testing',
|
| |
+ [self.bug1])
|
| |
+ self.update_testing2 = add_update('test-testing2.fc99', self.release, 'testing',
|
| |
+ [self.bug2])
|
| |
# add an update that fixes a bug which is an accepted Beta FE
|
| |
# and a proposed Beta blocker, and another bug which is an
|
| |
# accepted Final blocker, for fix function tests
|
| |
- betafebug = add_bug(9003, 'betafebug', cls.milestone)
|
| |
- betafebug.accepted_blocker = False
|
| |
- betafebug.proposed_blocker = True
|
| |
- betafebug.accepted_fe = True
|
| |
- cls.update_complex = add_update(u'test-complex1.fc99', u'testing',
|
| |
- [betafebug, finalbug],
|
| |
- cls.release, [cls.milestone, cls.finalmile])
|
| |
+ self.betafebug = add_bug(9003, 'betafebug', self.milestone)
|
| |
+ self.betafebug.accepted_blocker = False
|
| |
+ self.betafebug.proposed_blocker = True
|
| |
+ self.betafebug.accepted_fe = True
|
| |
+ self.update_complex = add_update('test-complex1.fc99', self.release, 'testing',
|
| |
+ [self.betafebug, self.finalbug])
|
| |
# also an update that fixes a proposed Beta FE and an accepted
|
| |
# Final FE for the same purpose
|
| |
- propbetafebug = add_bug(9004, 'propbetafebug', cls.milestone)
|
| |
- propbetafebug.accepted_blocker = False
|
| |
- propbetafebug.proposed_fe = True
|
| |
- finalfebug = add_bug(9005, 'finalfebug', cls.finalmile)
|
| |
- finalfebug.accepted_blocker = False
|
| |
- finalfebug.accepted_fe = True
|
| |
- cls.update_complexfe = add_update(u'test-complexfe.fc99', u'testing',
|
| |
- [propbetafebug, finalfebug],
|
| |
- cls.release, [cls.milestone, cls.finalmile])
|
| |
+ self.propbetafebug = add_bug(9004, 'propbetafebug', self.milestone)
|
| |
+ self.propbetafebug.accepted_blocker = False
|
| |
+ self.propbetafebug.proposed_fe = True
|
| |
+ self.finalfebug = add_bug(9005, 'finalfebug', self.finalmile)
|
| |
+ self.finalfebug.accepted_blocker = False
|
| |
+ self.finalfebug.accepted_fe = True
|
| |
+ self.update_complexfe = add_update('test-complexfe.fc99', self.release, 'testing',
|
| |
+ [self.propbetafebug, self.finalfebug])
|
| |
db.session.commit()
|
| |
|
| |
@classmethod
|
| |
- def teardown_class(cls):
|
| |
+ def teardown_method(self):
|
| |
db.session.rollback()
|
| |
+ db.session.close()
|
| |
db.drop_all()
|
| |
|
| |
- def test_get_pending_stable_updates(self):
|
| |
- updates = main.get_milestone_pending_stable_updates(self.milestone)
|
| |
- assert len(updates) == 1
|
| |
- update = updates[0]
|
| |
- assert self.update_pending_stable == update
|
| |
-
|
| |
-
|
| |
- def test_get_testing_status_and_has_bugs_updates(self):
|
| |
- updates = main.get_milestone_updates_testing(self.milestone)
|
| |
- assert len(updates) == 3
|
| |
- expected = [self.update_testing1, self.update_complex, self.update_complexfe]
|
| |
- updates.sort(key=lambda x: x.title)
|
| |
- expected.sort(key=lambda x: x.title)
|
| |
- assert updates == expected
|
| |
-
|
| |
- def test_get_milestone_all_nonstable_blocker_fixes(self):
|
| |
- updates = main.get_milestone_all_nonstable_blocker_fixes(self.milestone)
|
| |
- assert len(updates) == 3
|
| |
- # we should NOT find complex or complexfe here!
|
| |
- expected = [self.update_pending_stable, self.update_pending_testing, self.update_testing1]
|
| |
- updates.sort(key=lambda x: x.title)
|
| |
- expected.sort(key=lambda x: x.title)
|
| |
- assert updates == expected
|
| |
-
|
| |
- def test_get_milestone_all_nonstable_fe_fixes(self):
|
| |
- updates = main.get_milestone_all_nonstable_fe_fixes(self.milestone)
|
| |
+ def test_get_milestone_updates(self):
|
| |
+ updates = main.get_milestone_updates(self.milestone)
|
| |
+ assert set(updates) == set([self.update_pending_stable,
|
| |
+ self.update_stable1,
|
| |
+ self.update_pending_testing,
|
| |
+ self.update_testing1,
|
| |
+ self.update_complex,
|
| |
+ self.update_complexfe
|
| |
+ ])
|
| |
+
|
| |
+ def test_get_updates_nonstable_blockers(self):
|
| |
+ updates = main.get_updates_nonstable_blockers(self.milestone)
|
| |
+ assert set(updates) == set([self.update_pending_stable,
|
| |
+ self.update_pending_testing,
|
| |
+ self.update_testing1
|
| |
+ ])
|
| |
+
|
| |
+ def test_get_updates_nonstable_FEs(self):
|
| |
+ updates = main.get_updates_nonstable_FEs(self.milestone)
|
| |
# we should find complex (as it fixes an accepted Beta FE) but
|
| |
# NOT complexfe here!
|
| |
assert len(updates) == 1
|
| |
@@ -306,13 +306,16 @@
|
| |
|
| |
def test_requests(self):
|
| |
# we also test the requests template generation here, as it's
|
| |
- # what the _fixes queries back and it makes sense to do it
|
| |
+ # what the get_* queries provide and it makes sense to do it
|
| |
# with all these bits in place
|
| |
with app.app_context():
|
| |
- beta_response = main.display_release_requests(num=self.release.number,
|
| |
- release_name=self.milestone.version)
|
| |
- final_response = main.display_release_requests(num=self.release.number,
|
| |
- release_name=self.finalmile.version)
|
| |
+ beta_response = self.client.get(
|
| |
+ f'/milestone/{self.release.number}/{self.milestone.version}/requests')
|
| |
+ assert beta_response.status_code == 200
|
| |
+ final_response = self.client.get(
|
| |
+ f'/milestone/{self.release.number}/{self.finalmile.version}/requests')
|
| |
+ assert final_response.status_code == 200
|
| |
+
|
| |
# === beta milestone ===
|
| |
beta_requests = beta_response.get_data(as_text=True)
|
| |
print(beta_requests)
|
| |
@@ -350,7 +353,7 @@
|
| |
compose_blockers, compose_fes, push_blockers, push_fes, deps = all_sections
|
| |
|
| |
# check all the right updates and bugs are and are not in the correct sections
|
| |
- assert item_just_in("test-pending-stable", [], all_sections)
|
| |
+ assert item_just_in("test-pending-stable", [compose_blockers, push_blockers], all_sections)
|
| |
assert item_just_in("test-stable1", [], all_sections)
|
| |
assert item_just_in("test-stable2", [], all_sections)
|
| |
assert item_just_in("test-pending-testing", [], all_sections)
|
| |
@@ -363,10 +366,25 @@
|
| |
# bug 2 id
|
| |
assert item_just_in("9001", [], all_sections)
|
| |
# finalbug id
|
| |
- assert item_just_in("9002", [compose_blockers], all_sections)
|
| |
+ assert item_just_in("9002", [compose_blockers, push_blockers], all_sections)
|
| |
# betafebug id
|
| |
assert item_just_in("9003", [], all_sections)
|
| |
# propbetafebug id
|
| |
assert item_just_in("9004", [], all_sections)
|
| |
# finalfebug id
|
| |
assert item_just_in("9005", [compose_fes], all_sections)
|
| |
+
|
| |
+ def test_display_bug_updates(self):
|
| |
+ with app.app_context():
|
| |
+ for bug in [self.bug1, self.bug2, self.finalbug, self.betafebug, self.propbetafebug,
|
| |
+ self.finalfebug]:
|
| |
+ rv = self.client.get(f'/bug/{bug.bugid}/updates')
|
| |
+ assert rv.status_code == 200
|
| |
+ html = rv.get_data(as_text=True)
|
| |
+
|
| |
+ # make sure the right updates are listed
|
| |
+ for update in bug.updates.all():
|
| |
+ assert update.updateid in html
|
| |
+ # make sure there are no additional updates listed
|
| |
+ matches = re.findall(re.escape('<tr class="update">'), html)
|
| |
+ assert len(matches) == len(bug.updates.all())
|
| |
This is a big fat PR, but I couldn't split it into multiple logical commits, because it's all very connected. Sorry :-( But there are at least two separate commits. In the first one, I completely overhaul the
Update
model. In the second, I addcreate-test-data
command, which allows to populate your instance with handy bugs and updates, which help to display the changes that were done in the front-end, and will also surely be useful for future development.I understand this is a big changeset and is hard to review, but I would still appreciate someone at least roughly going through it and testing the upgrade and functionality on their local machine. @lbrabec, perhaps? ;-)
Here's the git summary of the two commits: