コード例 #1
0
    def test_raise_bug_fetch_error_connect_value_error(self):
        """Raise BugFetchError due to ValueError exception on connect."""
        connection = mock.MagicMock()
        connection.connect.side_effect = [ValueError()]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #2
0
    def test_raise_bug_fetch_error_connect_value_error(self):
        """Raise BugFetchError due to ValueError exception on connect."""
        connection = mock.MagicMock()
        connection.connect.side_effect = [ValueError()]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #3
0
    def test_raise_bug_fetch_error_getbugsimple_fault(self):
        """Raise BugFetchError due to Fault exception on getbugsimple."""
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [
            decorators.Fault(42, 'What is the answer?')]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #4
0
    def test_raise_bug_fetch_error_getbugsimple_fault(self):
        """Raise BugFetchError due to Fault exception on getbugsimple."""
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [
            decorators.Fault(42, 'What is the answer?')]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #5
0
    def test_raise_bug_fetch_error_getbugsimple_expaterror(self):
        """Raise BugFetchError due to an ExpatError exception on
        getbugsimple.
        """
        expaterror = decorators.ExpatError()
        expaterror.code = 12
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [expaterror]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #6
0
    def test_raise_bug_fetch_error_getbugsimple_expaterror(self):
        """Raise BugFetchError due to an ExpatError exception on
        getbugsimple.
        """
        expaterror = decorators.ExpatError()
        expaterror.code = 12
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [expaterror]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._redmine', {}):
            with self.assertRaises(decorators.BugFetchError):
                decorators._get_bugzilla_bug('4242')
コード例 #7
0
    def test_not_cached_bug(self):
        """Fetch bug information and cache it."""
        bug = {'id': 42}
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [bug]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._bugzilla', {}):
            self.assertEqual(id(decorators._get_bugzilla_bug('4242')), id(bug))
        connection.connect.assert_called_once_with(decorators.BUGZILLA_URL)
コード例 #8
0
    def test_not_cached_bug(self):
        """Fetch bug information and cache it."""
        bug = {'id': 42}
        connection = mock.MagicMock()
        connection.getbugsimple.side_effect = [bug]
        self.bugzilla.RHBugzilla.side_effect = [connection]

        with mock.patch.dict(
                'robottelo.decorators._bugzilla', {}):
            self.assertEqual(id(decorators._get_bugzilla_bug('4242')), id(bug))
        connection.connect.assert_called_once_with(decorators.BUGZILLA_URL)
コード例 #9
0
ファイル: test_decorators.py プロジェクト: elyezer/robottelo
    def test_not_cached_bug(self):
        """Fetch bug information and cache it."""
        bug = {'id': 42}
        connection = mock.MagicMock()
        connection.getbug.return_value = bug
        self.bugzilla.RHBugzilla.return_value = connection

        with mock.patch.dict(
                'robottelo.decorators._bugzilla', {}):
            self.assertEqual(id(decorators._get_bugzilla_bug('4242')), id(bug))
        self.bugzilla.RHBugzilla.assert_called_once_with(
            url=BUGZILLA_URL,
            user=self.settings.username,
            password=self.settings.password
        )
コード例 #10
0
    def test_not_cached_bug(self):
        """Fetch bug information and cache it."""
        bug = {'id': 4242}
        get_bug_data = self.BZReader.return_value.get_bug_data
        get_bug_data.return_value = bug

        with mock.patch.dict('robottelo.decorators._bugzilla', {}):
            self.assertIs(decorators._get_bugzilla_bug(bug['id']), bug)
        credentials = {
            'user': self.settings.username,
            'password': self.settings.password
        }
        self.BZReader.assert_called_once_with(credentials,
                                              include_fields=[
                                                  'id', 'status', 'whiteboard',
                                                  'flags', 'resolution',
                                                  'target_milestone'
                                              ],
                                              follow_clones=True)

        get_bug_data.assert_called_once_with(bug['id'])
コード例 #11
0
 def test_cached_bug(self):
     """Return bug information from the cache."""
     with mock.patch.dict(
             'robottelo.decorators._bugzilla', {'4242': 42}):
         self.assertEqual(decorators._get_bugzilla_bug('4242'), 42)
コード例 #12
0
 def test_cached_bug(self):
     """Return bug information from the cache."""
     with mock.patch.dict(
             'robottelo.decorators._bugzilla', {'4242': 42}):
         self.assertEqual(decorators._get_bugzilla_bug('4242'), 42)