def test_unregister_removes_consumer_cert_with_gone_correct_id(self, unregister_consumer_mock, clean_data_mock):
        unregister_consumer_mock.side_effect = connection.GoneException("", "", 112233)
        self._inject_mock_valid_consumer(uuid=112233)
        CacheManager.delete_cache = classmethod(lambda cls: None)

        cmd = managercli.UnRegisterCommand()
        cmd.main(['unregister'])

        clean_data_mock.assert_called_once_with(backup=False)
    def test_unregister_removes_consumer_cert(self, clean_data_mock):
        mock_injected_identity = self._inject_mock_valid_consumer()

        # When
        cmd = managercli.UnRegisterCommand()

        # CacheManager.delete_cache = classmethod(lambda cls: None)

        cmd.main([])
        self.assertEqual(mock_injected_identity.uuid, cmd.cp.called_unregister_uuid)
    def test_unregister_removes_consumer_cert_with_gone_correct_id(self, clean_data_mock):
        with patch("rhsm.connection.UEPConnection", new_callable=StubUEP) as mock_uep:
            mock_uep.unregisterConsumer = Mock(side_effect=connection.GoneException("", "", 112233))
            self.stub_cp_provider.consumer_auth_cp = mock_uep
            self._inject_mock_valid_consumer(uuid=112233)

            cmd = managercli.UnRegisterCommand()
            cmd.main([])

            self.assertTrue(mock_uep.unregisterConsumer.called)
            clean_data_mock.assert_called_once_with(backup=False)
Beispiel #4
0
    def test_unregister_removes_consumer_cert(self):
        connection.UEPConnection = StubUEP

        # When
        cmd = managercli.UnRegisterCommand()

        ConsumerIdentity.existsAndValid = classmethod(lambda cls: True)
        ConsumerIdentity.exists = classmethod(lambda cls: True)

        CacheManager.delete_cache = classmethod(lambda cls: None)

        def stub_consumer():
            return {'consumer_name': 'stub_name', 'uuid': 'stub_uuid'}

        managercli.check_registration = stub_consumer
        cmd.main(['unregister'])
        self.assertEquals('stub_uuid', cmd.cp.called_unregister_uuid)