Skip to content

Commit

Permalink
Execute skipped tests for Python 3
Browse files Browse the repository at this point in the history
Signed-off-by: Vismay Golwala <[email protected]>
  • Loading branch information
Vismay Golwala authored and mergify[bot] committed Aug 23, 2018
1 parent 7dda554 commit 44d46e3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 57 deletions.
4 changes: 2 additions & 2 deletions bodhi/server/consumers/masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def _wait_for_sync(self):
master_repomd_url = self._get_master_repomd_url(arch)

with open(repomd) as repomdf:
checksum = hashlib.sha1(repomdf.read()).hexdigest()
checksum = hashlib.sha1(repomdf.read().encode('utf-8')).hexdigest()
while True:
try:
self.log.info('Polling %s' % master_repomd_url)
Expand All @@ -1318,7 +1318,7 @@ def _wait_for_sync(self):
self.log.exception('Error fetching repomd.xml')
time.sleep(200)
continue
newsum = hashlib.sha1(masterrepomd.read()).hexdigest()
newsum = hashlib.sha1(masterrepomd.read().encode('utf-8')).hexdigest()
if newsum == checksum:
self.log.info("master repomd.xml matches!")
notifications.publish(
Expand Down
48 changes: 24 additions & 24 deletions bodhi/tests/server/consumers/test_masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from click import testing
import mock
from kitchen.text.converters import to_bytes
import six
import six.moves.urllib.parse as urlparse
from six.moves.urllib.error import HTTPError, URLError
Expand Down Expand Up @@ -555,7 +556,6 @@ def test_tag_ordering(self, publish, *args):
self.assertEqual(self.koji.__moved__[1],
(u'f17-updates-candidate', u'f17-updates-testing', u'bodhi-2.0-2.fc17'))

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_taskotron_results)
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._wait_for_pungi')
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._sanity_check_repo')
Expand Down Expand Up @@ -595,11 +595,12 @@ def test_testing_digest(self, mail, *args):
""" % time.strftime('%Y'))

mail.assert_called_with(config.get('bodhi_email'), config.get('fedora_test_announce_list'),
mail.assert_called_with(to_bytes(config.get('bodhi_email')),
to_bytes(config.get('fedora_test_announce_list')),
mock.ANY)
assert len(mail.mock_calls) == 2, len(mail.mock_calls)
body = mail.mock_calls[1][1][2]
assert body.startswith(
assert body.decode('utf-8').startswith(
('From: [email protected]\r\nTo: %s\r\nX-Bodhi: fedoraproject.org\r\nSubject: '
'Fedora 17 updates-testing report\r\n\r\nThe following builds have been pushed to '
'Fedora 17 updates-testing\n\n bodhi-2.0-1.fc17\n\nDetails about builds:\n\n\n====='
Expand Down Expand Up @@ -1042,7 +1043,6 @@ def test_security_update_priority_testing(self, publish, *args):
force=True,
topic='mashtask.complete'))

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_taskotron_results)
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._wait_for_pungi')
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._sanity_check_repo')
Expand Down Expand Up @@ -1094,6 +1094,12 @@ def test_security_updates_parallel(self, publish, *args):
self.masher.consume(self._make_msg())

# Ensure that F18 and F17 run in parallel
# If F17 is executed first, it will publish messages on 5 topics:
# [ mashtask.mashing, buildroot_override.untag, update.complete.stable,
# errata.publish, mashtask.complete ]. So, F18 mashing call is expected on calls[6].
#
# On other hand if F18 is executed first, it will publish 4 of the above messages
# except `buildroot_override.untag` and so, F17 call is expected on calls[5].
calls = publish.mock_calls
if calls[1] == mock.call(
msg={'repo': u'f18-updates',
Expand All @@ -1102,25 +1108,24 @@ def test_security_updates_parallel(self, publish, *args):
'agent': 'bowlofeggs'},
force=True, topic='mashtask.mashing'):
self.assertEqual(
calls[2],
calls[5],
mock.call(msg={'repo': u'f17-updates',
'ctype': 'rpm',
'updates': [u'bodhi-2.0-1.fc17'],
'agent': 'bowlofeggs'},
force=True, topic='mashtask.mashing'))
elif calls[1] == self.assertEqual(
calls[1],
mock.call(
msg={'repo': u'f17-updates',
'ctype': 'rpm',
'updates': [u'bodhi-2.0-1.fc17'],
'agent': 'bowlofeggs'},
force=True, topic='mashtask.mashing')):
elif calls[1] == mock.call(
msg={'repo': u'f17-updates',
'ctype': 'rpm',
'updates': [u'bodhi-2.0-1.fc17'],
'agent': 'bowlofeggs'},
force=True, topic='mashtask.mashing'):
self.assertEqual(
calls[2],
calls[6],
mock.call(msg={'repo': u'f18-updates',
'ctype': 'rpm',
'updates': [u'bodhi-2.0-1.fc18']},
'updates': [u'bodhi-2.0-1.fc18'],
'agent': 'bowlofeggs'},
force=True, topic='mashtask.mashing'))

@mock.patch('bodhi.server.notifications.publish')
Expand Down Expand Up @@ -1306,7 +1311,6 @@ def test_mash(self, publish, *args):
'status_comments': True})
self.assertTrue(os.path.exists(mash_dir))

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_taskotron_results)
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._sanity_check_repo')
@mock.patch('bodhi.server.consumers.masher.PungiComposerThread._stage_repo')
Expand Down Expand Up @@ -1366,10 +1370,10 @@ def test_mash_module(self, publish, *args):
force=True,
msg=mock.ANY)

self.assertEqual(t._module_defs, [{'context': '2',
'version': '20172',
'name': 'testmodule',
'stream': 'master'}])
self.assertEqual(list(t._module_defs), [{'context': '2',
'version': '20172',
'name': 'testmodule',
'stream': 'master'}])
self.assertEqual(t._module_list, ['testmodule:master:20172'])

EXPECTED_VARIANTS = '''Raw NSVs:
Expand Down Expand Up @@ -2723,7 +2727,6 @@ def test_without_state(self):

class TestPungiComposerThread__wait_for_sync(ComposerThreadBaseTestCase):
"""This test class contains tests for the PungiComposerThread._wait_for_sync() method."""
@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_testing_master_repomd':
Expand Down Expand Up @@ -2797,7 +2800,6 @@ def test_no_checkarch(self, urlopen, publish):
except Exception as ex:
assert str(ex) == "Not found an arch to _wait_for_sync with"

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_testing_master_repomd':
Expand Down Expand Up @@ -2841,7 +2843,6 @@ def test_checksum_match_third_try(self, urlopen, sleep, publish):
urlopen.assert_has_calls(expected_calls)
sleep.assert_has_calls([mock.call(200), mock.call(200)])

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_testing_master_repomd':
Expand Down Expand Up @@ -2945,7 +2946,6 @@ def test_missing_repomd(self, publish):
t.log.error.assert_called_once_with(
'Cannot find local repomd: %s', os.path.join(repodata, 'repomd.xml'))

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch.dict(
'bodhi.server.consumers.masher.config',
{'fedora_testing_master_repomd':
Expand Down
43 changes: 17 additions & 26 deletions bodhi/tests/server/services/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import copy
import textwrap
import time
import unittest

from mock import ANY
import koji
Expand All @@ -35,7 +34,7 @@
from bodhi.server.models import (
BuildrootOverride, Compose, Group, RpmPackage, ModulePackage, Release,
ReleaseState, RpmBuild, Update, UpdateRequest, UpdateStatus, UpdateType,
UpdateSeverity, User, TestGatingStatus)
UpdateSeverity, UpdateSuggestion, User, TestGatingStatus)
from bodhi.server.util import call_api
from bodhi.tests.server.base import BaseTestCase, BodhiTestApp

Expand Down Expand Up @@ -524,7 +523,6 @@ def test_new_update_with_multiple_bugs_as_str(self, publish, *args):
self.assertEqual(up['bugs'][1]['bug_id'], 5678)
self.assertEqual(up['bugs'][2]['bug_id'], 12345)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch.dict('bodhi.server.validators.config', {'acl_system': u'dummy'})
@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.server.notifications.publish')
Expand All @@ -535,7 +533,7 @@ def test_new_update_with_invalid_bugs_as_str(self, publish, *args):
up = r.json_body
self.assertEqual(up['status'], 'error')
self.assertEqual(up['errors'][0]['description'],
"Invalid bug ID specified: [u'1234', u'blargh']")
"Invalid bug ID specified: {}".format([u'1234', u'blargh']))

@mock.patch.dict('bodhi.server.validators.config', {'acl_system': u'dummy'})
@mock.patch(**mock_valid_requirements)
Expand Down Expand Up @@ -887,7 +885,6 @@ def test_home_html_no_legal(self):
self.assertNotIn('Legal</a>', resp)
self.assertNotIn('http://loweringthebar.net/', resp)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_edit_add_build_from_different_release(self):
"""Editing an update that references builds from other releases should raise an error."""
update = self.db.query(Update).one()
Expand All @@ -906,11 +903,10 @@ def test_edit_add_build_from_different_release(self):
u'errors': [
{u'description': (
u"Cannot find release associated with build: bodhi-3.2.0-1.fc27, "
u"tags: [u'f27-updates-candidate', u'f27', u'f27-updates-testing']"),
u"tags: {}".format([u'f27-updates-candidate', u'f27', u'f27-updates-testing'])),
u'location': u'body', u'name': u'builds'}]}
self.assertEqual(res.json, expected_json)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_edit_invalidly_tagged_build(self):
"""Editing an update that references invalidly tagged builds should raise an error."""
update = self.db.query(Update).one()
Expand All @@ -930,7 +926,7 @@ def test_edit_invalidly_tagged_build(self):
u'errors': [
{u'description': (
u"Invalid tag: bodhi-2.0-1.fc17 not tagged with any of the following tags "
u"[u'f17-updates-candidate', u'f17-updates-testing']"),
u"{}".format([u'f17-updates-candidate', u'f17-updates-testing'])),
u'location': u'body', u'name': u'builds'}]}
self.assertEqual(res.json, expected_json)
listTags.assert_called_once_with('bodhi-2.0-1.fc17')
Expand Down Expand Up @@ -1585,7 +1581,6 @@ def test_updates_search(self):
up = body['updates'][0]
self.assertEqual(up['title'], u'bodhi-2.0-1.fc17')

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_valid_requirements)
def test_list_updates_pagination(self, *args):

Expand Down Expand Up @@ -1736,14 +1731,13 @@ def test_list_updates_by_bugs(self):
self.assertEqual(len(up['bugs']), 1)
self.assertEqual(up['bugs'][0]['bug_id'], 12345)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_invalid_bug(self):
res = self.app.get('/updates/', {"bugs": "cockroaches"}, status=400)
body = res.json_body
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'bugs')
self.assertEqual(res.json_body['errors'][0]['description'],
"Invalid bug ID specified: [u'cockroaches']")
"Invalid bug ID specified: {}".format([u'cockroaches']))

def test_list_updates_by_unexisting_bug(self):
res = self.app.get('/updates/', {"bugs": "19850110"})
Expand Down Expand Up @@ -2346,16 +2340,15 @@ def test_list_updates_by_request(self):
self.assertEqual(up['alias'], u'FEDORA-%s-a3bbe1a8f2' % YEAR)
self.assertEqual(up['karma'], 1)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_unexisting_request(self):
res = self.app.get('/updates/', {"request": "impossible"},
status=400)
body = res.json_body
request_vals = ", ".join(UpdateRequest.values())
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'request')
self.assertEqual(res.json_body['errors'][0]['description'],
u'"impossible" is not one of revoke, testing,'
' obsolete, batched, stable, unpush')
u'"impossible" is not one of {}'.format(request_vals))

def test_list_updates_by_severity(self):
res = self.app.get('/updates/', {"severity": "medium"})
Expand All @@ -2381,15 +2374,15 @@ def test_list_updates_by_severity(self):
self.assertEqual(up['alias'], u'FEDORA-%s-a3bbe1a8f2' % YEAR)
self.assertEqual(up['karma'], 1)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_unexisting_severity(self):
res = self.app.get('/updates/', {"severity": "schoolmaster"},
status=400)
body = res.json_body
severity_vals = ", ".join(UpdateSeverity.values())
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'severity')
self.assertEqual(res.json_body['errors'][0]['description'],
'"schoolmaster" is not one of high, urgent, medium, low, unspecified')
'"schoolmaster" is not one of {}'.format(severity_vals))

def test_list_updates_by_status(self):
res = self.app.get('/updates/', {"status": "pending"})
Expand Down Expand Up @@ -2450,17 +2443,16 @@ def test_list_updates_by_status_inactive_release(self):
body = res.json_body
self.assertEqual(len(body['updates']), 0)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_unexisting_status(self):
res = self.app.get('/updates/', {"status": "single"},
status=400)
body = res.json_body
status_vals = ", ".join(UpdateStatus.values())
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'status')
self.assertEqual(
res.json_body['errors'][0]['description'],
('"single" is not one of testing, side_tag_expired, processing, obsolete, '
'pending, stable, unpushed, side_tag_active'))
('"single" is not one of {}'.format(status_vals)))

def test_list_updates_by_suggest(self):
res = self.app.get('/updates/', {"suggest": "unspecified"})
Expand All @@ -2486,15 +2478,15 @@ def test_list_updates_by_suggest(self):
self.assertEqual(up['alias'], u'FEDORA-%s-a3bbe1a8f2' % YEAR)
self.assertEqual(up['karma'], 1)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_unexisting_suggest(self):
res = self.app.get('/updates/', {"suggest": "no idea"},
status=400)
body = res.json_body
suggest_vals = ", ".join(UpdateSuggestion.values())
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'suggest')
self.assertEqual(res.json_body['errors'][0]['description'],
'"no idea" is not one of logout, reboot, unspecified')
'"no idea" is not one of {}'.format(suggest_vals))

def test_list_updates_by_type(self):
res = self.app.get('/updates/', {"type": "bugfix"})
Expand All @@ -2520,15 +2512,15 @@ def test_list_updates_by_type(self):
self.assertEqual(up['alias'], u'FEDORA-%s-a3bbe1a8f2' % YEAR)
self.assertEqual(up['karma'], 1)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_list_updates_by_unexisting_type(self):
res = self.app.get('/updates/', {"type": "not_my"},
status=400)
body = res.json_body
type_vals = ", ".join(UpdateType.values())
self.assertEqual(len(body.get('updates', [])), 0)
self.assertEqual(res.json_body['errors'][0]['name'], 'type')
self.assertEqual(res.json_body['errors'][0]['description'],
'"not_my" is not one of newpackage, bugfix, security, enhancement')
'"not_my" is not one of {}'.format(type_vals))

def test_list_updates_by_username(self):
res = self.app.get('/updates/', {"user": "guest"})
Expand Down Expand Up @@ -3108,7 +3100,6 @@ def test_disabled_button_for_autopush(self, *args):
self.assertIn(nvr, resp)
self.assertIn('Disabled', resp)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_taskotron_results)
@mock.patch(**mock_valid_requirements)
def test_invalid_request(self, *args):
Expand All @@ -3118,10 +3109,11 @@ def test_invalid_request(self, *args):
'/updates/%s/request' % args['builds'],
{'request': 'foo', 'csrf_token': self.get_csrf_token()}, status=400)
resp = resp.json_body
request_vals = ", ".join(UpdateRequest.values())
self.assertEqual(resp['status'], 'error')
self.assertEqual(
resp['errors'][0]['description'],
u'"foo" is not one of revoke, testing, obsolete, batched, stable, unpush')
u'"foo" is not one of {}'.format(request_vals))

# Now try with None
resp = self.app.post_json(
Expand Down Expand Up @@ -4422,7 +4414,6 @@ def test_push_to_batched_button_present_when_test_gating_status_passed(self, pub
self.assertNotIn('Push to Stable', resp)
self.assertIn('Edit', resp)

@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.server.notifications.publish')
def test_push_to_batched_button_present_when_karma_reached(self, publish, *args):
Expand Down
7 changes: 2 additions & 5 deletions bodhi/tests/server/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@
import datetime
import mock
import re
import unittest

import PIL.Image
from six import StringIO
import six
from six import BytesIO

from bodhi.server import main
from bodhi.tests.server import base


class TestRenderers(base.BaseTestCase):
@unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
def test_renderer_jpeg(self):
"""
Test that the renderer returns a jpeg. In this case, the CAPTCHA image.
Expand Down Expand Up @@ -61,6 +58,6 @@ def test_renderer_jpeg(self):
captcha_url = re.search(r'"http://localhost(/captcha/[^"]*)"', str(res)).groups()[0]
resp = app.get(captcha_url, status=200)
self.assertIn('image/jpeg', resp.headers['Content-Type'])
jpegdata = StringIO(resp.body)
jpegdata = BytesIO(resp.body)
img = PIL.Image.open(jpegdata)
self.assertEqual(img.size, (300, 80))

0 comments on commit 44d46e3

Please sign in to comment.