def setUp(self): # By default mock that we are registered. Individual test cases # can override if they are testing disconnected scenario. id_mock = Mock() id_mock.exists_and_valid = Mock(return_value=True) # Don't really care about date ranges here: self.mock_calc = NonCallableMock() self.mock_calc.calculate.return_value = None inj.provide(inj.IDENTITY, id_mock) inj.provide(inj.PRODUCT_DATE_RANGE_CALCULATOR, self.mock_calc) inj.provide(inj.STATUS_CACHE, stubs.StubStatusCache()) inj.provide(inj.PROD_STATUS_CACHE, stubs.StubProductStatusCache()) # By default set up an empty stub entitlement and product dir. # Tests need to modify or create their own but nothing should hit # the system. self.ent_dir = stubs.StubEntitlementDirectory() inj.provide(inj.ENT_DIR, self.ent_dir) self.prod_dir = stubs.StubProductDirectory() inj.provide(inj.PROD_DIR, self.prod_dir) inj.provide(inj.CP_PROVIDER, stubs.StubCPProvider()) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) # setup and mock the plugin_manager plugin_manager_mock = Mock() inj.provide(inj.PLUGIN_MANAGER, plugin_manager_mock) inj.provide(inj.DBUS_IFACE, Mock()) self.dbus_patcher = patch( 'subscription_manager.managercli.CliCommand._request_validity_check' ) self.dbus_patcher.start()
def setUp(self): # By default mock that we are registered. Individual test cases # can override if they are testing disconnected scenario. id_mock = NonCallableMock(name='FixtureIdentityMock') id_mock.exists_and_valid = Mock(return_value=True) id_mock.uuid = 'fixture_identity_mock_uuid' id_mock.name = 'fixture_identity_mock_name' # Don't really care about date ranges here: self.mock_calc = NonCallableMock() self.mock_calc.calculate.return_value = None inj.provide(inj.IDENTITY, id_mock) inj.provide(inj.PRODUCT_DATE_RANGE_CALCULATOR, self.mock_calc) inj.provide(inj.ENTITLEMENT_STATUS_CACHE, stubs.StubEntitlementStatusCache()) inj.provide(inj.PROD_STATUS_CACHE, stubs.StubProductStatusCache()) inj.provide(inj.OVERRIDE_STATUS_CACHE, stubs.StubOverrideStatusCache()) inj.provide(inj.PROFILE_MANAGER, stubs.StubProfileManager()) # By default set up an empty stub entitlement and product dir. # Tests need to modify or create their own but nothing should hit # the system. self.ent_dir = stubs.StubEntitlementDirectory() inj.provide(inj.ENT_DIR, self.ent_dir) self.prod_dir = stubs.StubProductDirectory() inj.provide(inj.PROD_DIR, self.prod_dir) # Installed products manager needs PROD_DIR injected first inj.provide(inj.INSTALLED_PRODUCTS_MANAGER, stubs.StubInstalledProductsManager()) self.stub_cp_provider = stubs.StubCPProvider() self._release_versions = [] self.stub_cp_provider.content_connection.get_versions = self._get_release_versions inj.provide(inj.CP_PROVIDER, self.stub_cp_provider) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) # setup and mock the plugin_manager plugin_manager_mock = Mock(name='FixturePluginManagerMock') inj.provide(inj.PLUGIN_MANAGER, plugin_manager_mock) inj.provide(inj.DBUS_IFACE, Mock(name='FixtureDbusIfaceMock')) pooltype_cache = Mock() inj.provide(inj.POOLTYPE_CACHE, pooltype_cache) # don't use file based locks for tests inj.provide(inj.ACTION_LOCK, RLock) self.stub_facts = stubs.StubFacts() inj.provide(inj.FACTS, self.stub_facts) self.dbus_patcher = patch( 'subscription_manager.managercli.CliCommand._request_validity_check' ) self.dbus_patcher.start()
def setUp(self): stub_content = stubs.StubContent("c1", required_tags='rhel-6', gpg=None, enabled="1") # this content should be ignored since it's not enabled stub_content_2 = stubs.StubContent("c2", required_tags='rhel-6', gpg=None, enabled="0") # this should be ignored because of required_tag isn't what we # are looking for stub_content_3 = stubs.StubContent("c3", required_tags="NotAwesomeOS", gpg=None, enabled="1") # this should be ignored because of required_tag isn't what we # are looking for, and it is not enabled stub_content_4 = stubs.StubContent("c4", required_tags="NotAwesomeOS", gpg=None, enabled="0") stub_contents = [ stub_content, stub_content_2, stub_content_3, stub_content_4 ] stub_product = stubs.StubProduct("rhel-6") stub_entitlement_certs = [ stubs.StubEntitlementCertificate(stub_product, content=stub_contents) ] stub_entitlement_dir = stubs.StubEntitlementDirectory( stub_entitlement_certs) stub_product_dir = stubs.StubProductDirectory([ stubs.StubProductCertificate( stubs.StubProduct("rhel-6", provided_tags="rhel-6-stub"), ) ]) def get_versions(dummy): return versions stub_content_connection = stubs.StubContentConnection() stub_content_connection.get_versions = get_versions self.rb = release.ReleaseBackend( ent_dir=stub_entitlement_dir, prod_dir=stub_product_dir, content_connection=stub_content_connection)
def _getPrefDialog(self): stub_backend = stubs.StubBackend() stub_backend.cp_provider.consumer_auth_cp.setConsumer(CONSUMER_DATA) stub_backend.product_dir = stubs.StubCertificateDirectory([stubs.StubProductCertificate(stubs.StubProduct("rhel-6"))]) stub_backend.entitlement_dir = stubs.StubEntitlementDirectory([stubs.StubEntitlementCertificate(stubs.StubProduct("rhel-6"))]) self.preferences_dialog = preferences.PreferencesDialog(backend=stub_backend, parent=None) self.preferences_dialog.release_backend.facts = stubs.StubFacts() self.preferences_dialog.release_backend.get_releases = get_releases self.preferences_dialog.async_updater = stubs.StubAsyncUpdater(self.preferences_dialog)
def setUp(self): fixture.SubManFixture.setUp(self) stub_content = stubs.StubContent("c1", required_tags='rhel-6', gpg=None, enabled="1") # this content should be ignored since it's not enabled stub_content_2 = stubs.StubContent("c2", required_tags='rhel-6', gpg=None, enabled="0") # this should be ignored because of required_tag isn't what we # are looking for stub_content_3 = stubs.StubContent("c3", required_tags="NotAwesomeOS", gpg=None, enabled="1") # this should be ignored because of required_tag isn't what we # are looking for, and it is not enabled stub_content_4 = stubs.StubContent("c4", required_tags="NotAwesomeOS", gpg=None, enabled="0") stub_contents = [ stub_content, stub_content_2, stub_content_3, stub_content_4 ] stub_product = stubs.StubProduct("rhel-6") stub_entitlement_certs = [ stubs.StubEntitlementCertificate(stub_product, content=stub_contents) ] # the fixtures ent_dir self.ent_dir = stubs.StubEntitlementDirectory(stub_entitlement_certs) # fixtures prod_dir self.prod_dir = stubs.StubProductDirectory([ stubs.StubProductCertificate( stubs.StubProduct("rhel-6", provided_tags="rhel-6,rhel-6-stub"), ) ]) # FIXME: should just mock this # fixture knows to stub this for contentConnection self._release_versions = versions
def _stub_certificate_calls(self, stub_ents=None): stub_ents = stub_ents or [] stub_ent_dir = stubs.StubEntitlementDirectory(stub_ents) inj.provide(inj.ENT_DIR, stub_ent_dir) # don't need to build real pem's, we mock out the writer anyway # so this just create a list of mock keys and stub ent certs stub_certificate_list = [] for stub_cert in self.local_ent_certs: stub_certificate_list.append((mock.Mock(), stub_cert)) # return a list of stub ent certs, could be new stubs, but # we already have created that self.mock_uep.getCertificates.return_value = stub_certificate_list
def test_get_releases_rhel_no_content(self): stub_content_5 = stubs.StubContent("c5", required_tags="AwesomeOS", gpg=None, enabled="1") stub_product = stubs.StubProduct("rhel-6") stub_entitlement_certs = [stubs.StubEntitlementCertificate(stub_product, content=[stub_content_5])] self.ent_dir = stubs.StubEntitlementDirectory(stub_entitlement_certs) rb = self._get_rb() releases = rb.get_releases() self.assertEquals([], releases)
def _create_async_pool(self): provide(inj.CP_PROVIDER, stubs.StubCPProvider()) inj.provide(inj.PROD_DIR, stubs.StubProductDirectory()) inj.provide(inj.ENT_DIR, stubs.StubEntitlementDirectory()) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) self.pool_stash = \ managerlib.PoolStash() self.ap = async .AsyncPool(self.pool_stash) # add a timeout and a idle handler self.idle = ga_GObject.idle_add(self.ap.refresh, datetime.date.today(), self.idle_callback) self.timer = ga_GObject.timeout_add(50, self.idle_callback) self.mainloop = ga_GObject.MainLoop()
def setUp(self): self.stub_backend = stubs.StubBackend() self.stub_consumer = stubs.StubConsumer() self.stub_facts = stubs.StubFacts() self.stub_backend.uep.getConsumer = self._getConsumerData self.stub_product = stubs.StubProduct("rhel-6") self.stub_pool = modelhelpers.create_pool( product_id=self.stub_product.getHash(), product_name=self.stub_product.getName()) self.stub_backend.uep.stub_pool = self.stub_pool self.stub_backend.product_dir = stubs.StubCertificateDirectory( [stubs.StubProductCertificate(self.stub_product)]) self.stub_backend.entitlement_dir = stubs.StubEntitlementDirectory([]) self.stub_backend.uep.dryRunBind = self._dryRunBind
def test_get_releases_rhel_no_enabled_content(self): stub_content_6 = stubs.StubContent("c6", required_tags="rhel-6", gpg=None, enabled="0") stub_product = stubs.StubProduct("rhel-6") stub_entitlement_certs = [ stubs.StubEntitlementCertificate(stub_product, content=[stub_content_6]) ] self.ent_dir = stubs.StubEntitlementDirectory(stub_entitlement_certs) cdn_rv_provider = self._get_cdn_rv_provider() releases = cdn_rv_provider.get_releases() self.assertEquals([], releases)
def _getPrefDialog(self): stub_backend = stubs.StubBackend() stub_backend.uep.getConsumer = getConsumerData if self._getConsumerData: stub_backend.uep.getConsumer = self._getConsumerData self.consumer = StubConsumer() if self._getConsumer: self.consumer = self._getConsumer() stub_backend.product_dir = stubs.StubCertificateDirectory( [stubs.StubProductCertificate(stubs.StubProduct("rhel-6"))]) stub_backend.entitlement_dir = stubs.StubEntitlementDirectory( [stubs.StubEntitlementCertificate(stubs.StubProduct("rhel-6"))]) self.preferences_dialog = preferences.PreferencesDialog( backend=stub_backend, consumer=self.consumer, parent=None) self.preferences_dialog.release_backend.facts = stubs.StubFacts() self.preferences_dialog.release_backend.get_releases = get_releases
def _create_async_pool(self): id_mock = mock.Mock() id_mock.uuid = 'some-consumer-uuid' provide(IDENTITY, id_mock) provide(inj.CP_PROVIDER, stubs.StubCPProvider()) inj.provide(inj.PROD_DIR, stubs.StubProductDirectory()) inj.provide(inj.ENT_DIR, stubs.StubEntitlementDirectory()) facts_mock = mock.Mock() facts_mock.update_check.return_value = None self.pool_stash = \ managerlib.PoolStash(backend=stubs.StubBackend(uep=ListPoolsStubUEP()), facts=facts_mock) self.ap = async.AsyncPool(self.pool_stash) # add a timeout and a idle handler self.idle = gobject.idle_add(self.ap.refresh, datetime.date.today(), self.idle_callback) self.timer = gobject.timeout_add(50, self.idle_callback) self.mainloop = gobject.MainLoop()
def test_autobind_all_products_covered(self): self.stub_backend.entitlement_dir = stubs.StubEntitlementDirectory( [stubs.StubEntitlementCertificate(self.stub_product)]) autobind_controller = self._get_autobind_controller() self.assertRaises(autobind.AllProductsCoveredException, autobind_controller.load)
def setUp(self): SubManFixture.setUp(self) # we have to have a reference to the patchers self.patcher2 = mock.patch.object(certlib.UpdateAction, '_get_consumer_id') self.certlib_updateaction_getconsumerid = self.patcher2.start() self.patcher3 = mock.patch.object(repolib.UpdateAction, 'perform') self.repolib_updateaction_perform = self.patcher3.start() self.patcher4 = mock.patch( 'subscription_manager.factlib.ConsumerIdentity') self.factlib_consumeridentity = self.patcher4.start() self.patcher5 = mock.patch( 'subscription_manager.certlib.ConsumerIdentity') self.certlib_consumeridentity = self.patcher5.start() self.patcher6 = mock.patch( 'subscription_manager.managerlib.persist_consumer_cert') self.managerlib_persist_consumer_cert = self.patcher6.start() self.patcher8 = mock.patch.object(facts.Facts, 'get_last_update') self.facts_getlastupdate = self.patcher8.start() # mock out all hardware fetching... we may need to fake socket counts self.hwprobe_getall_patcher = mock.patch.object( hwprobe.Hardware, 'get_all') self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start() self.hwprobe_getall_mock.return_value = {} self.patcher_certlib_writer = mock.patch( "subscription_manager.certlib.Writer") self.certlib_writer = self.patcher_certlib_writer.start() self.patcher_certlib_action_syslogreport = mock.patch.object( certlib.UpdateAction, 'syslog_results') self.update_action_syslog_mock = self.patcher_certlib_action_syslogreport.start( ) # some stub certs stub_product = stubs.StubProduct('stub_product') self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product) self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product) self.stub_ent_expires_tomorrow = \ stubs.StubEntitlementCertificate(stub_product, end_date=datetime.now() + timedelta(days=1)) self.stub_ent_expires_tomorrow_entdir = \ stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow]) self.local_ent_certs = [self.stub_ent1, self.stub_ent2] self.stub_entitled_proddir = \ stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)]) # local entitlement dir self.stub_entdir = stubs.StubEntitlementDirectory(self.local_ent_certs) inj.provide(inj.ENT_DIR, self.stub_entdir) self.mock_uep = mock.Mock() self.mock_uep.getCertificateSerials = mock.Mock( return_value=[{ 'serial': self.stub_ent1.serial }, { 'serial': self.stub_ent2.serial }]) self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA) self.certlib_updateaction_getconsumerid.return_value = "234234" self.repolib_updateaction_perform.return_value = 0 self.facts_getlastupdate.return_value = None self.factlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity( "sdfsdf", "sdfsdf") self.certlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity( "sdfsdf", "sdfsdf") # Setup a mock cert sorter to initiate the behaviour we want to test. # Must use a non-callable mock for our features dep injection # framework. self.mock_cert_sorter = mock.NonCallableMock() injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
def setUp(self): SubManFixture.setUp(self) # we have to have a reference to the patchers #self.patcher2 = mock.patch.object(entcertlib.EntCertUpdateAction, '_get_consumer_id') #self.entcertlib_updateaction_getconsumerid = self.patcher2.start() self.patcher3 = mock.patch.object(repolib.RepoUpdateActionCommand, 'perform') self.repolib_updateaction_perform = self.patcher3.start() self.patcher6 = mock.patch( 'subscription_manager.managerlib.persist_consumer_cert') self.managerlib_persist_consumer_cert = self.patcher6.start() # mock out all hardware fetching... we may need to fake socket counts self.hwprobe_getall_patcher = mock.patch.object( hwprobe.Hardware, 'get_all') self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start() self.hwprobe_getall_mock.return_value = {} self.patcher_entcertlib_writer = mock.patch( "subscription_manager.entcertlib.Writer") self.entcertlib_writer = self.patcher_entcertlib_writer.start() self.patcher_entcertlib_action_syslogreport = mock.patch.object( entcertlib.EntCertUpdateAction, 'syslog_results') self.update_action_syslog_mock = self.patcher_entcertlib_action_syslogreport.start( ) # some stub certs stub_product = stubs.StubProduct('stub_product') self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product) self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product) self.stub_ent_expires_tomorrow = \ stubs.StubEntitlementCertificate(stub_product, end_date=datetime.now() + timedelta(days=1)) self.stub_ent_expires_tomorrow_ent_dir = \ stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow]) self.local_ent_certs = [self.stub_ent1, self.stub_ent2] self.stub_entitled_proddir = \ stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)]) # local entitlement dir self.stub_ent_dir = stubs.StubEntitlementDirectory( self.local_ent_certs) inj.provide(inj.ENT_DIR, self.stub_ent_dir) self.mock_uep = mock.Mock() self.mock_uep.getCertificateSerials = mock.Mock( return_value=[{ 'serial': self.stub_ent1.serial }, { 'serial': self.stub_ent2.serial }]) self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA) self.set_consumer_auth_cp(self.mock_uep) stub_release = {'releaseVer': '6.4'} self.mock_uep.getRelease = mock.Mock(return_value=stub_release) # we need to mock the consumers uuid with the mocked GoneExceptions # uuid self._inject_mock_valid_consumer(uuid="234234") self.repolib_updateaction_perform.return_value = 0 # Setup a mock cert sorter to initiate the behaviour we want to test. # Must use a non-callable mock for our features dep injection # framework. self.mock_cert_sorter = mock.NonCallableMock() # TODO: need to provide return for "getRelease" for repolib stuff injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
def setUp(self): # By default mock that we are registered. Individual test cases # can override if they are testing disconnected scenario. id_mock = NonCallableMock(name='FixtureIdentityMock') id_mock.exists_and_valid = Mock(return_value=True) id_mock.uuid = 'fixture_identity_mock_uuid' id_mock.name = 'fixture_identity_mock_name' id_mock.cert_dir_path = "/not/a/real/path/to/pki/consumer/" # Don't really care about date ranges here: self.mock_calc = NonCallableMock() self.mock_calc.calculate.return_value = None # Avoid trying to read real /etc/yum.repos.d/redhat.repo self.mock_repofile_path_exists_patcher = patch('subscription_manager.repolib.RepoFile.path_exists') mock_repofile_path_exists = self.mock_repofile_path_exists_patcher.start() mock_repofile_path_exists.return_value = True inj.provide(inj.IDENTITY, id_mock) inj.provide(inj.PRODUCT_DATE_RANGE_CALCULATOR, self.mock_calc) inj.provide(inj.ENTITLEMENT_STATUS_CACHE, stubs.StubEntitlementStatusCache()) inj.provide(inj.PROD_STATUS_CACHE, stubs.StubProductStatusCache()) inj.provide(inj.OVERRIDE_STATUS_CACHE, stubs.StubOverrideStatusCache()) inj.provide(inj.RELEASE_STATUS_CACHE, stubs.StubReleaseStatusCache()) inj.provide(inj.PROFILE_MANAGER, stubs.StubProfileManager()) # By default set up an empty stub entitlement and product dir. # Tests need to modify or create their own but nothing should hit # the system. self.ent_dir = stubs.StubEntitlementDirectory() inj.provide(inj.ENT_DIR, self.ent_dir) self.prod_dir = stubs.StubProductDirectory() inj.provide(inj.PROD_DIR, self.prod_dir) # Installed products manager needs PROD_DIR injected first inj.provide(inj.INSTALLED_PRODUCTS_MANAGER, stubs.StubInstalledProductsManager()) self.stub_cp_provider = stubs.StubCPProvider() self._release_versions = [] self.stub_cp_provider.content_connection.get_versions = self._get_release_versions inj.provide(inj.CP_PROVIDER, self.stub_cp_provider) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) # setup and mock the plugin_manager plugin_manager_mock = MagicMock(name='FixturePluginManagerMock') plugin_manager_mock.runiter.return_value = iter([]) inj.provide(inj.PLUGIN_MANAGER, plugin_manager_mock) inj.provide(inj.DBUS_IFACE, Mock(name='FixtureDbusIfaceMock')) pooltype_cache = Mock() inj.provide(inj.POOLTYPE_CACHE, pooltype_cache) # don't use file based locks for tests inj.provide(inj.ACTION_LOCK, RLock) self.stub_facts = stubs.StubFacts() inj.provide(inj.FACTS, self.stub_facts) self.dbus_patcher = patch('subscription_manager.managercli.CliCommand._request_validity_check') self.dbus_patcher.start() # No tests should be trying to connect to any configure or test server # so really, everything needs this mock. May need to be in __init__, or # better, all test classes need to use SubManFixture self.is_valid_server_patcher = patch("subscription_manager.managercli.is_valid_server_info") is_valid_server_mock = self.is_valid_server_patcher.start() is_valid_server_mock.return_value = True self.files_to_cleanup = []
def setUp(self): # No matter what, stop all patching (even if we have a failure in setUp itself) self.addCleanup(patch.stopall) # Never attempt to use the actual managercli.cfg which points to a # real file in etc. self.mock_cfg_parser = stubs.StubConfig() original_conf = subscription_manager.managercli.conf def unstub_conf(): subscription_manager.managercli.conf = original_conf # Mock makes it damn near impossible to mock a module attribute (which we shouldn't be using # in the first place because it's terrible) so we monkey-patch it ourselves. # TODO Fix this idiocy by not reading the damn config on module import subscription_manager.managercli.conf = config.Config( self.mock_cfg_parser) self.addCleanup(unstub_conf) facts_host_patcher = patch('rhsmlib.dbus.facts.FactsClient', auto_spec=True) self.mock_facts_host = facts_host_patcher.start() self.mock_facts_host.return_value.GetFacts.return_value = self.set_facts( ) # By default mock that we are registered. Individual test cases # can override if they are testing disconnected scenario. id_mock = NonCallableMock(name='FixtureIdentityMock') id_mock.exists_and_valid = Mock(return_value=True) id_mock.uuid = 'fixture_identity_mock_uuid' id_mock.name = 'fixture_identity_mock_name' id_mock.cert_dir_path = "/not/a/real/path/to/pki/consumer/" id_mock.keypath.return_value = "/not/a/real/key/path" id_mock.certpath.return_value = "/not/a/real/cert/path" # Don't really care about date ranges here: self.mock_calc = NonCallableMock() self.mock_calc.calculate.return_value = None # Avoid trying to read real /etc/yum.repos.d/redhat.repo self.mock_repofile_path_exists_patcher = patch( 'subscription_manager.repolib.RepoFile.path_exists') mock_repofile_path_exists = self.mock_repofile_path_exists_patcher.start( ) mock_repofile_path_exists.return_value = True inj.provide(inj.IDENTITY, id_mock) inj.provide(inj.PRODUCT_DATE_RANGE_CALCULATOR, self.mock_calc) inj.provide(inj.ENTITLEMENT_STATUS_CACHE, stubs.StubEntitlementStatusCache()) inj.provide(inj.PROD_STATUS_CACHE, stubs.StubProductStatusCache()) inj.provide(inj.OVERRIDE_STATUS_CACHE, stubs.StubOverrideStatusCache()) inj.provide(inj.RELEASE_STATUS_CACHE, stubs.StubReleaseStatusCache()) inj.provide(inj.PROFILE_MANAGER, stubs.StubProfileManager()) # By default set up an empty stub entitlement and product dir. # Tests need to modify or create their own but nothing should hit # the system. self.ent_dir = stubs.StubEntitlementDirectory() inj.provide(inj.ENT_DIR, self.ent_dir) self.prod_dir = stubs.StubProductDirectory() inj.provide(inj.PROD_DIR, self.prod_dir) # Installed products manager needs PROD_DIR injected first inj.provide(inj.INSTALLED_PRODUCTS_MANAGER, stubs.StubInstalledProductsManager()) self.stub_cp_provider = stubs.StubCPProvider() self._release_versions = [] self.stub_cp_provider.content_connection.get_versions = self._get_release_versions inj.provide(inj.CP_PROVIDER, self.stub_cp_provider) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) # setup and mock the plugin_manager plugin_manager_mock = MagicMock(name='FixturePluginManagerMock') plugin_manager_mock.runiter.return_value = iter([]) inj.provide(inj.PLUGIN_MANAGER, plugin_manager_mock) inj.provide(inj.DBUS_IFACE, Mock(name='FixtureDbusIfaceMock')) pooltype_cache = Mock() inj.provide(inj.POOLTYPE_CACHE, pooltype_cache) # don't use file based locks for tests inj.provide(inj.ACTION_LOCK, RLock) self.stub_facts = stubs.StubFacts() inj.provide(inj.FACTS, self.stub_facts) content_access_cache_mock = MagicMock(name='ContentAccessCacheMock') inj.provide(inj.CONTENT_ACCESS_CACHE, content_access_cache_mock) self.dbus_patcher = patch( 'subscription_manager.managercli.CliCommand._request_validity_check' ) self.dbus_patcher.start() # No tests should be trying to connect to any configure or test server # so really, everything needs this mock. May need to be in __init__, or # better, all test classes need to use SubManFixture self.is_valid_server_patcher = patch( "subscription_manager.managercli.is_valid_server_info") is_valid_server_mock = self.is_valid_server_patcher.start() is_valid_server_mock.return_value = True # No tests should be trying to test the proxy connection # so really, everything needs this mock. May need to be in __init__, or # better, all test classes need to use SubManFixture self.test_proxy_connection_patcher = patch( "subscription_manager.managercli.CliCommand.test_proxy_connection") test_proxy_connection_mock = self.test_proxy_connection_patcher.start() test_proxy_connection_mock.return_value = True self.files_to_cleanup = []