mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Fix failing unit tests.
These tests began failing after a correction to another test. The other test had been patching the error_out function without unpatching it and thus polluted the test environment. Also reset to a known directory at the beginning of the common tests so that we don't start in a directory that has since been unlinked.
This commit is contained in:
parent
f98e12e866
commit
6fedf5850e
1 changed files with 16 additions and 9 deletions
|
@ -16,9 +16,10 @@
|
|||
from tito.common import (replace_version, find_spec_like_file, increase_version,
|
||||
search_for, compare_version, run_command_print, find_wrote_in_rpmbuild_output,
|
||||
render_cheetah, increase_zstream, reset_release, find_file_with_extension,
|
||||
normalize_class_name, extract_sha1, BugzillaExtractor
|
||||
normalize_class_name, extract_sha1, BugzillaExtractor, DEFAULT_BUILD_DIR
|
||||
)
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock, patch, call
|
||||
|
@ -27,6 +28,10 @@ from unit import open_mock
|
|||
|
||||
|
||||
class CommonTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Start in a known location to prevent problems with tests that
|
||||
# end in a temp directory that is subsequently deleted.
|
||||
os.chdir(DEFAULT_BUILD_DIR)
|
||||
|
||||
def test_normalize_class_name(self):
|
||||
""" Test old spacewalk.releng namespace is converted to tito. """
|
||||
|
@ -411,10 +416,10 @@ class ExtractBugzillasTest(unittest.TestCase):
|
|||
self.assertEquals("Resolves: #987654 - Such amaze!",
|
||||
results[1])
|
||||
|
||||
def test_required_flags_missing(self):
|
||||
|
||||
extractor = BugzillaExtractor("", required_flags=[
|
||||
'myos-2.0+'])
|
||||
@patch("tito.common.error_out")
|
||||
def test_required_flags_missing(self, mock_error):
|
||||
required_flags = ['myos-2.0+']
|
||||
extractor = BugzillaExtractor("", required_flags)
|
||||
bug1 = ('123456', 'Did something interesting.')
|
||||
bug2 = ('444555', 'Something else.')
|
||||
bug3 = ('987654', 'Such amaze!')
|
||||
|
@ -436,6 +441,7 @@ class ExtractBugzillasTest(unittest.TestCase):
|
|||
|
||||
self.assertEquals(0, len(extractor.bzs))
|
||||
self.assertEquals(0, len(results))
|
||||
mock_error.assert_called_once_with("No bugzillas found with required flags: %s" % required_flags)
|
||||
|
||||
def test_required_flags_missing_with_placeholder(self):
|
||||
|
||||
|
@ -483,10 +489,10 @@ class ExtractBugzillasTest(unittest.TestCase):
|
|||
self.assertEquals("Resolves: #123456 - Oops, lets try again.",
|
||||
results[1])
|
||||
|
||||
def test_bug_doesnt_exist(self):
|
||||
|
||||
extractor = BugzillaExtractor("", required_flags=[
|
||||
'myos-1.0+', 'pm_ack+'])
|
||||
@patch("tito.common.error_out")
|
||||
def test_bug_doesnt_exist(self, mock_error):
|
||||
required_flags = ['myos-1.0+', 'pm_ack+']
|
||||
extractor = BugzillaExtractor("", required_flags)
|
||||
bug1 = ('123456', 'Did something interesting.')
|
||||
extractor._extract_bzs = Mock(return_value=[
|
||||
bug1])
|
||||
|
@ -499,6 +505,7 @@ class ExtractBugzillasTest(unittest.TestCase):
|
|||
|
||||
self.assertEquals(0, len(extractor.bzs))
|
||||
self.assertEquals(0, len(results))
|
||||
mock_error.assert_called_once_with("No bugzillas found with required flags: %s" % required_flags)
|
||||
|
||||
|
||||
class MockBug(object):
|
||||
|
|
Loading…
Add table
Reference in a new issue