Skip to content

Commit

Permalink
Fix some tests that relied on it being 2017.
Browse files Browse the repository at this point in the history
fixes #2109

Signed-off-by: Randy Barlow <[email protected]>
  • Loading branch information
bowlofeggs committed Jan 16, 2018
1 parent ca4320c commit 7ee19a1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
6 changes: 4 additions & 2 deletions bodhi/tests/server/consumers/test_masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ def test_mash_no_found_dirs(self, save_state):
t.wait_for_mash(fake_popen)
assert False, "Mash without generated dirs did not crash"
except Exception as ex:
assert str(ex) == 'We were unable to find a path with prefix ' + \
'Fedora-17-updates-testing-2017* in mashdir'
expected_error = ('We were unable to find a path with prefix '
'Fedora-17-updates-testing-{}* in mashdir')
expected_error = expected_error.format(datetime.datetime.utcnow().year)
assert str(ex) == expected_error
t.db = None

@mock.patch('bodhi.server.consumers.masher.MasherThread.save_state')
Expand Down
41 changes: 26 additions & 15 deletions bodhi/tests/server/scripts/test_check_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""This module contains tests for the bodhi.server.scripts.check_policies module."""
import datetime

from click import testing
from mock import patch
Expand Down Expand Up @@ -52,9 +53,11 @@ def test_policies_satisfied(self):

expected_query = {
'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',
'subject': [{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-2017-a3bbe1a8f2', 'type': 'bodhi_update'}]}
'subject': [
{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
'type': 'bodhi_update'}]}
mock_greenwave.assert_called_once_with(config['greenwave_api_url'] + '/decision',
expected_query)

Expand Down Expand Up @@ -82,9 +85,11 @@ def test_policies_pending_satisfied(self):

expected_query = {
'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_testing',
'subject': [{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-2017-a3bbe1a8f2', 'type': 'bodhi_update'}]}
'subject': [
{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
'type': 'bodhi_update'}]}
mock_greenwave.assert_called_once_with(config['greenwave_api_url'] + '/decision',
expected_query)

Expand Down Expand Up @@ -116,9 +121,11 @@ def test_policies_unsatisfied(self):

expected_query = {
'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',
'subject': [{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-2017-a3bbe1a8f2', 'type': 'bodhi_update'}]}
'subject': [
{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
'type': 'bodhi_update'}]}
mock_greenwave.assert_called_once_with(config['greenwave_api_url'] + '/decision',
expected_query)

Expand All @@ -145,9 +152,11 @@ def test_no_policies_enforced(self):
self.assertTrue(update.test_gating_status is None)
expected_query = {
'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',
'subject': [{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-2017-a3bbe1a8f2', 'type': 'bodhi_update'}]}
'subject': [
{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
'type': 'bodhi_update'}]}
mock_greenwave.assert_called_once_with(config['greenwave_api_url'] + '/decision',
expected_query)

Expand Down Expand Up @@ -204,8 +213,10 @@ def test_unrestricted_policy(self):

expected_query = {
'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',
'subject': [{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-2017-a3bbe1a8f2', 'type': 'bodhi_update'}]}
'subject': [
{'item': u'bodhi-2.0-1.fc17', 'type': 'koji_build'},
{'original_spec_nvr': u'bodhi-2.0-1.fc17'},
{'item': u'FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
'type': 'bodhi_update'}]}
mock_greenwave.assert_called_once_with(config['greenwave_api_url'] + '/decision',
expected_query)
8 changes: 5 additions & 3 deletions bodhi/tests/server/services/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,16 @@ def test_edit_with_permission(self):
"""
Test a logged in User with permissions on the update can see the form
"""
resp = self.app.get('/updates/FEDORA-2017-a3bbe1a8f2/edit')
resp = self.app.get('/updates/FEDORA-{}-a3bbe1a8f2/edit'.format(datetime.utcnow().year))
self.assertIn('Editing an update requires JavaScript', resp)

def test_edit_without_permission(self):
"""
Test a logged in User without permissions on the update can't see the form
"""
app = TestApp(main({}, testing=u'anonymous', session=self.db, **self.app_settings))
resp = app.get('/updates/FEDORA-2017-a3bbe1a8f2/edit', status=400)
resp = app.get(
'/updates/FEDORA-{}-a3bbe1a8f2/edit'.format(datetime.utcnow().year), status=400)
self.assertIn(
'anonymous is not a member of "packager", which is a mandatory packager group', resp)

Expand Down Expand Up @@ -1245,7 +1246,8 @@ def test_updates_search(self):
self.assertEquals(len(body['updates']), 0)

# test a search for an alias
res = self.app.get('/updates/', {'search': 'FEDORA-2017-a3bbe1a8f2'})
res = self.app.get(
'/updates/', {'search': 'FEDORA-{}-a3bbe1a8f2'.format(datetime.utcnow().year)})
body = res.json_body
self.assertEquals(len(body['updates']), 1)
up = body['updates'][0]
Expand Down
6 changes: 4 additions & 2 deletions bodhi/tests/server/test_renderers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2017 Red Hat, Inc.
# -*- coding: utf-8 -*-
# Copyright © 2017 Red Hat, Inc.
#
# This file is part of Bodhi.
#
Expand All @@ -17,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import copy
import datetime
import re
import StringIO

Expand Down Expand Up @@ -50,7 +52,7 @@ def test_renderer_jpeg(self):
})
app = TestApp(main({}, session=self.db, **settings))

res = app.get('/updates/FEDORA-2017-a3bbe1a8f2',
res = app.get('/updates/FEDORA-{}-a3bbe1a8f2'.format(datetime.datetime.utcnow().year),
status=200,
headers=dict(accept='text/html'))
captcha_url = re.search(r'"http://localhost(/captcha/[^"]*)"', str(res)).groups()[0]
Expand Down
1 change: 1 addition & 0 deletions bodhi/tests/server/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import subprocess
import unittest

import mock
import pkgdb2client
Expand Down

0 comments on commit 7ee19a1

Please sign in to comment.