From 92dad605a5daebfd36b1f15967d35c6e84bb3c86 Mon Sep 17 00:00:00 2001 From: FrantiĊĦek Zatloukal Date: Aug 15 2018 07:33:43 +0000 Subject: Use Munch instead of py2-only Bunch --- diff --git a/blockerbugs.spec b/blockerbugs.spec index a3586dc..11b77ae 100644 --- a/blockerbugs.spec +++ b/blockerbugs.spec @@ -35,7 +35,7 @@ Requires: koji BuildRequires: python-devel BuildRequires: python-setuptools BuildRequires: pytest -BuildRequires: python-bunch +BuildRequires: python-munch BuildRequires: python-flask BuildRequires: python-flask-sqlalchemy BuildRequires: python-fedora-flask diff --git a/blockerbugs/util/login.py b/blockerbugs/util/login.py index 1f7d41d..d5632bb 100644 --- a/blockerbugs/util/login.py +++ b/blockerbugs/util/login.py @@ -20,13 +20,13 @@ # Authors: # Martin Krizek -import bunch +import munch from flask import g, request, redirect class FakeFas(object): fake_user_groups = ['qa-admin'] - fake_user = bunch.Bunch(username='developer', + fake_user = munch.Munch(username='developer', groups=fake_user_groups) def __init__(self, app): diff --git a/requirements.txt b/requirements.txt index 72f38c8..addd89b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ Jinja2>=2.7.2 SQLAlchemy>=0.9.7 WTForms>=2.0 Werkzeug==0.9.1 -bunch==1.0.1 +munch>=1.0.1 mock>=0.8.0 py>=1.4.9 pytest>=2.3.5 diff --git a/setup.py b/setup.py index 4d6fef4..8753924 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ setup(name='blockerbugs', 'Flask>=0.9', 'Flask-SQLAlchemy>=0.16', 'SQLAlchemy>= 0.7', - 'bunch>=1.0.1', + 'munch>=1.0.1', 'python-bugzilla>=0.8', 'Flask-SQLAlchemy>=0.16', 'WTForms>1.0', diff --git a/testing/test_bugsync_extract_information.py b/testing/test_bugsync_extract_information.py index 90e3973..f6882d4 100644 --- a/testing/test_bugsync_extract_information.py +++ b/testing/test_bugsync_extract_information.py @@ -1,10 +1,10 @@ -from bunch import Bunch +from munch import Munch from copy import deepcopy from blockerbugs.util.bug_sync import BugSync from mock import MagicMock import datetime -basicbug = Bunch({'bug_id': 123456, +basicbug = Munch({'bug_id': 123456, 'weburl': 'https://bugzilla.redhat.com/show_bug.cgi?id=123456', 'component': 'randomcomponent', 'status': 'NEW', diff --git a/testing/test_updatesync_extract_information.py b/testing/test_updatesync_extract_information.py index 2fdab5b..5c8f2f1 100644 --- a/testing/test_updatesync_extract_information.py +++ b/testing/test_updatesync_extract_information.py @@ -1,11 +1,11 @@ -from bunch import Bunch +from munch import Munch from copy import deepcopy from blockerbugs.util.update_sync import UpdateSync from mock import MagicMock from datetime import datetime -basicupdate = Bunch( +basicupdate = Munch( approved=None, close_bugs=True, critpath=False, @@ -22,10 +22,10 @@ basicupdate = Bunch( unstable_karma=-3, updateid=u'FEDORA-2012-13902', url=u'https://bodhi.stg.fedoraproject.org/FEDORA-2012-13902', - bugs=[Bunch(bug_id=856836, parent=False, security=False, + bugs=[Munch(bug_id=856836, parent=False, security=False, title=u'/etc/fstab is not written correctly after live install (F18 Alpha RC2+)')], - builds=[Bunch(nvr=u'anaconda-18.6.8-1.fc18', - package=Bunch( + builds=[Munch(nvr=u'anaconda-18.6.8-1.fc18', + package=Munch( committers=[u'anaconda-maint', u'dlehman', u'jkeating', u'bcl', u'clumens', u'rvykydal', u'akozumpl', u'pjones', @@ -34,44 +34,44 @@ basicupdate = Bunch( name=u'anaconda', suggest_reboot=False))], comments=[ - Bunch(anonymous=False, author=u'bodhi', group=None, + Munch(anonymous=False, author=u'bodhi', group=None, karma=0, text=u'This update has been submitted for testing by bcl. ', timestamp=u'2012-09-12 23:43:24', update_title=u'anaconda-18.6.8-1.fc18'), - Bunch(anonymous=False, author=u'autoqa', group=None, + Munch(anonymous=False, author=u'autoqa', group=None, karma=0, text=u'AutoQA: depcheck test PASSED on x86_64. Result log:\nhttp://autoqa.fedoraproject.org/report/em84 (results are informative only)', timestamp=u'2012-09-13 00:14:41', update_title=u'anaconda-18.6.8-1.fc18'), - Bunch(anonymous=False, author=u'autoqa', group=None, + Munch(anonymous=False, author=u'autoqa', group=None, karma=0, text=u'AutoQA: depcheck test PASSED on i386. Result log:\nhttp://autoqa.fedoraproject.org/report/emcl (results are informative only)', timestamp=u'2012-09-13 00:30:53', update_title=u'anaconda-18.6.8-1.fc18'), - Bunch(anonymous=False, author=u'jkeating', + Munch(anonymous=False, author=u'jkeating', group=u'proventesters', karma=1, text=u'While I did not test the above bug, I have tested anaconda in a number of other\nscenarios and it performs as expected.', timestamp=u'2012-09-13 06:27:03', update_title=u'anaconda-18.6.8-1.fc18'), - Bunch(anonymous=False, author=u'bodhi', group=None, + Munch(anonymous=False, author=u'bodhi', group=None, karma=0, text=u'This update is currently being pushed to the Fedora 18 testing updates repository.', timestamp=u'2012-09-13 15:58:32', update_title=u'anaconda-18.6.8-1.fc18'), - Bunch(anonymous=False, author=u'bodhi', group=None, + Munch(anonymous=False, author=u'bodhi', group=None, karma=0, text=u'This update has been pushed to testing', timestamp=u'2012-09-13 16:44:30', update_title=u'anaconda-18.6.8-1.fc18')], - nagged=Bunch( + nagged=Munch( test_cases=[ u'QA:Testcase Anaconda autopart install', u'QA:Testcase Anaconda User Interface Graphical', u'QA:Testcase Boot Methods Pxeboot', u'QA:Testcase install repository Live Image', ]), - release=Bunch(dist_tag=u'f18', id_prefix=u'FEDORA', + release=Munch(dist_tag=u'f18', id_prefix=u'FEDORA', locked=True, long_name=u'Fedora 18', name=u'F18') ) @@ -179,7 +179,7 @@ class TestUpdateSyncExtractInformation(object): assert updateinfo['date_pushed_stable'] == None def test_extract_bug_single(self): - ref_bugs = [Bunch(bug_id=123456, parent=False, security=False, + ref_bugs = [Munch(bug_id=123456, parent=False, security=False, title=u'First wonderful test bug') ] self.testupdate.bugs = ref_bugs @@ -191,11 +191,11 @@ class TestUpdateSyncExtractInformation(object): def test_extract_bug_multiple(self): ref_bugs = [ - Bunch(bug_id=123456, parent=False, security=False, + Munch(bug_id=123456, parent=False, security=False, title=u'First wonderful test bug'), - Bunch(bug_id=234567, parent=False, security=False, + Munch(bug_id=234567, parent=False, security=False, title=u'Second wonderful test bug'), - Bunch(bug_id=345678, parent=False, security=False, + Munch(bug_id=345678, parent=False, security=False, title=u'Third wonderful test bug'), ] self.testupdate.bugs = ref_bugs diff --git a/testing/testfunc_bugsync.py b/testing/testfunc_bugsync.py index 602ed70..7d46ad5 100644 --- a/testing/testfunc_bugsync.py +++ b/testing/testfunc_bugsync.py @@ -1,5 +1,5 @@ import copy -from bunch import Bunch +from munch import Munch import datetime from blockerbugs.models.milestone import Milestone @@ -8,7 +8,7 @@ from blockerbugs.models.bug import Bug from blockerbugs import db from blockerbugs.util.bug_sync import BugSync -templatebug = Bunch({ +templatebug = Munch({ 'bug_id': 123456, 'weburl': 'https://bugzilla.redhat.com/show_bug.cgi?id=123456', 'component': 'randomcomponent', @@ -223,7 +223,7 @@ class TestfuncBugsync(object): assert len(test_syncbugs) == 2 - # this isn't done yet, need to monkey with the db schema and want to + # this isn't done yet, need to monkey with the db schema and want to # commit current work first test_syncbug = Bug.query.filter_by(bugid=self.basicbug.bug_id, milestone=newer_milestone).first() @@ -232,7 +232,7 @@ class TestfuncBugsync(object): assert test_syncbug.proposed_blocker assert not test_syncbug.accepted_blocker - # when a accepted blocker is closed, it should be left alone except for + # when a accepted blocker is closed, it should be left alone except for # marking the active feild false def should_closed_accepted_inactive(self): tracker_type = 'Blocker' diff --git a/testing/testfunc_update_sync.py b/testing/testfunc_update_sync.py index 40ee6a2..70bfa96 100644 --- a/testing/testfunc_update_sync.py +++ b/testing/testfunc_update_sync.py @@ -2,7 +2,7 @@ from itertools import chain from datetime import datetime from copy import copy -from bunch import Bunch +from munch import Munch from mock import patch, Mock from fedora.client import ServerError @@ -15,7 +15,7 @@ from testing.test_controllers import add_bug # only required part of a Bodhi response -base_update = Bunch( +base_update = Munch( title=u'anaconda-18.6.8-1.fc18', date_pushed=u'2012-09-13 16:40:28', date_submitted=u'2012-09-12 23:43:04', @@ -24,11 +24,11 @@ base_update = Bunch( stable_karma=3, status=u'pending', bugs=[ - Bunch(bug_id=2000, parent=False, security=False, + Munch(bug_id=2000, parent=False, security=False, title=u'bodhi bug 2000 title'), - Bunch(bug_id=2001, parent=False, security=False, + Munch(bug_id=2001, parent=False, security=False, title=u'bodhi bug 2001 title')], - release=Bunch(dist_tag=u'f99', id_prefix=u'FEDORA', locked=True, + release=Munch(dist_tag=u'f99', id_prefix=u'FEDORA', locked=True, long_name=u'Fedora 99', name=u'F99'), updateid='FEDORA-2012-13902', url=u'https://bodhi.stg.fedoraproject.org/FEDORA-2012-13902', @@ -39,14 +39,14 @@ update_for_bugs_2000_2001 = copy(base_update) update1_for_bug_3000 = copy(base_update) update1_for_bug_3000.update({ 'title': u'libreport-2.1.3-2.fc19', - 'bugs': [Bunch(bug_id=3000, parent=False, security=False, + 'bugs': [Munch(bug_id=3000, parent=False, security=False, title=u"anaconda can't report traceback to bugzilla")], }) update2_for_bug_3000 = copy(base_update) update2_for_bug_3000.update({ 'title': u'jboss-servlet-2.5-api-1.0.1-3.fc19,resteasy-2.3.2-12.fc19', - 'bugs': [Bunch(bug_id=3000, parent=False, security=False, + 'bugs': [Munch(bug_id=3000, parent=False, security=False, title=u"anaconda can't report traceback to bugzilla")], }) @@ -67,7 +67,7 @@ class FakeBodhiInterface(object): def query(self, release=None, bugs=None, **kwargs): updates = list(chain(*(self.updates[(release, bug)] for bug in bugs))) - return Bunch(updates=updates, + return Munch(updates=updates, page=1, pages=1, rows_per_page=20, @@ -75,7 +75,7 @@ class FakeBodhiInterface(object): class FakeErrorBodhiInterface(object): def query(self, **kwargs): - return Bunch(errors=[Bunch(location=u"querystring", + return Munch(errors=[Munch(location=u"querystring", name=u"release", description=u"Unknown release u'f99'")], status=u"error")