def test_http_fail(self, cache_save, cache_valid, fake_consumer_id, fake_uep): fake_uep().conn.request_put.side_effect = RemoteServerException(500) cache_valid.return_value = False enabled_repos_upload.upload_enabled_repos_report(Mock()) # validation cache_save.assert_not_called()
def raise_remote_server_exception(*args, **kwargs): """Raise remote server exception (uploading of profile failed)""" from rhsm.connection import RemoteServerException raise RemoteServerException( 502, request_type="PUT", handler="/subscription/consumers/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/profiles" )
def test_validate_registration_not_found(self, valid, read, get_consumer): consumer_id = '1234' valid.return_value = True read.return_value.getConsumerId.return_value = consumer_id get_consumer.side_effect = RemoteServerException(httplib.NOT_FOUND) # test self.plugin.validate_registration() # validation get_consumer.assert_called_with(consumer_id) self.assertFalse(self.plugin.registered)
def test_validate_registration_failed(self, valid, read, get_consumer): consumer_id = '1234' valid.return_value = True read.return_value.getConsumerId.return_value = consumer_id get_consumer.side_effect = RemoteServerException(httplib.BAD_REQUEST) # test self.assertRaises(RemoteServerException, self.plugin.validate_registration) # validation get_consumer.assert_called_with(consumer_id) self.assertFalse(self.plugin.registered)