def test_rpm_repo(self, mock_get_distributor): """ Test retrieving a valid repository and getting its type from the notes """ # Setup mock_get_distributor.return_value = {'notes': {'_repo-type': 'rpm-repo'}} # Test self.assertTrue(export_utils.is_rpm_repo('repo_id')) self.assertEqual('repo_id', mock_get_distributor.call_args[0][1])
def test_missing_type_repo(self, mock_get_distributor): """ An edge case, but if a repo is missing a _repo-type note, return False instead of raising a KeyError """ # Setup mock_get_distributor.side_effect = KeyError('boop') # Test self.assertFalse(export_utils.is_rpm_repo('repo_id')) self.assertEqual('repo_id', mock_get_distributor.call_args[0][1])
def test_invalid_repo(self, mock_get_distributor): """ Test that is_rpm_repo handles non-existent repository ids gracefully by returning False instead of raising a MissingResource exception """ # Setup mock_get_distributor.side_effect = MissingResource('this repo_id is non-existent') # Test self.assertFalse(export_utils.is_rpm_repo('repo_id')) self.assertEqual('repo_id', mock_get_distributor.call_args[0][1])