示例#1
0
    def test_missing_resource(self, mock_get_distributor):
        """
        Test that when the manager fails to find the yum distributor for a repo, the repo id is used
        as a relative url instead.
        """
        # Setup
        mock_get_distributor.side_effect = MissingResource('boop')

        # Test
        result = export_utils.get_repo_relative_url('repo_id')
        self.assertEqual(result, 'repo_id')
示例#2
0
    def test_key_error(self, mock_get_distributor):
        """
        Test that when the manager fails to find the relative url in the config due to a key error,
        the repo id is used instead.
        """
        # Setup
        mock_get_distributor.side_effect = KeyError('boop')

        # Test
        result = export_utils.get_repo_relative_url('repo_id')
        self.assertEqual(result, 'repo_id')
示例#3
0
    def test_get_repo_relative_url(self, mock_get_distributor):
        """
        Test that the relative url is successfully extracted from the yum distributor if it exists
        """
        # Setup
        mock_get_distributor.return_value = {'config': {'relative_url': 'relative/url'}}

        # Test
        result = export_utils.get_repo_relative_url('repo_id')
        self.assertEqual('repo_id', mock_get_distributor.call_args[0][1])
        self.assertEqual(ids.TYPE_ID_DISTRIBUTOR_YUM, mock_get_distributor.call_args[0][2])
        self.assertEqual(result, 'relative/url')