class DistributorScratchpadMixinTests(base.PulpServerTests): def clean(self): super(DistributorScratchpadMixinTests, self).clean() types_database.clean() Repo.get_collection().remove() def setUp(self): super(DistributorScratchpadMixinTests, self).setUp() mock_plugins.install() self.repo_manager = RepoManager() self.distributor_manager = RepoDistributorManager() repo_id = 'repo-1' self.repo_manager.create_repo(repo_id) self.distributor_manager.add_distributor( repo_id, 'mock-distributor', {}, True, distributor_id='test-distributor') self.conduit = DistributorScratchPadMixin(repo_id, 'test-distributor') def tearDown(self): super(DistributorScratchpadMixinTests, self).tearDown() manager_factory.reset() def test_get_set_scratchpad(self): """ Tests scratchpad calls. """ # Test - get no scratchpad self.assertTrue(self.conduit.get_scratchpad() is None) # Test - set scrathpad value = 'dragon' self.conduit.set_scratchpad(value) # Test - get updated value self.assertEqual(value, self.conduit.get_scratchpad()) def test_scratchpad_with_error(self): # Setup mock_distributor_manager = mock.Mock() mock_distributor_manager.get_distributor_scratchpad.side_effect = Exception( ) mock_distributor_manager.set_distributor_scratchpad.side_effect = Exception( ) manager_factory._INSTANCES[ manager_factory.TYPE_REPO_DISTRIBUTOR] = mock_distributor_manager # Test self.assertRaises(DistributorConduitException, self.conduit.get_scratchpad) self.assertRaises(DistributorConduitException, self.conduit.set_scratchpad, 'foo')
class DistributorScratchpadMixinTests(base.PulpServerTests): def clean(self): super(DistributorScratchpadMixinTests, self).clean() types_database.clean() Repo.get_collection().remove() def setUp(self): super(DistributorScratchpadMixinTests, self).setUp() mock_plugins.install() self.repo_manager = RepoManager() self.distributor_manager = RepoDistributorManager() repo_id = 'repo-1' self.repo_manager.create_repo(repo_id) self.distributor_manager.add_distributor(repo_id, 'mock-distributor', {}, True, distributor_id='test-distributor') self.conduit = DistributorScratchPadMixin(repo_id, 'test-distributor') def tearDown(self): super(DistributorScratchpadMixinTests, self).tearDown() manager_factory.reset() mock_plugins.reset() def test_get_set_scratchpad(self): """ Tests scratchpad calls. """ # Test - get no scratchpad self.assertTrue(self.conduit.get_scratchpad() is None) # Test - set scrathpad value = 'dragon' self.conduit.set_scratchpad(value) # Test - get updated value self.assertEqual(value, self.conduit.get_scratchpad()) def test_scratchpad_with_error(self): # Setup mock_distributor_manager = mock.Mock() mock_distributor_manager.get_distributor_scratchpad.side_effect = Exception() mock_distributor_manager.set_distributor_scratchpad.side_effect = Exception() manager_factory._INSTANCES[manager_factory.TYPE_REPO_DISTRIBUTOR] = mock_distributor_manager # Test self.assertRaises(DistributorConduitException, self.conduit.get_scratchpad) self.assertRaises(DistributorConduitException, self.conduit.set_scratchpad, 'foo')
def __init__(self, repo_id, distributor_id): """ @param repo_id: identifies the repo being published @type repo_id: str @param distributor_id: identifies the distributor being published @type distributor_id: str """ RepoScratchPadMixin.__init__(self, repo_id, DistributorConduitException) DistributorScratchPadMixin.__init__(self, repo_id, distributor_id) StatusMixin.__init__(self, distributor_id, DistributorConduitException) SingleRepoUnitsMixin.__init__(self, repo_id, DistributorConduitException) PublishReportMixin.__init__(self) self.repo_id = repo_id self.distributor_id = distributor_id
def setUp(self): super(DistributorScratchpadMixinTests, self).setUp() mock_plugins.install() self.repo_manager = RepoManager() self.distributor_manager = RepoDistributorManager() repo_id = 'repo-1' self.repo_manager.create_repo(repo_id) self.distributor_manager.add_distributor( repo_id, 'mock-distributor', {}, True, distributor_id='test-distributor') self.conduit = DistributorScratchPadMixin(repo_id, 'test-distributor')
def setUp(self): super(DistributorScratchpadMixinTests, self).setUp() mock_plugins.install() self.repo_manager = RepoManager() self.distributor_manager = RepoDistributorManager() repo_id = 'repo-1' self.repo_manager.create_repo(repo_id) self.distributor_manager.add_distributor(repo_id, 'mock-distributor', {}, True, distributor_id='test-distributor') self.conduit = DistributorScratchPadMixin(repo_id, 'test-distributor')