Repository: getmoto/moto

Issue:
put_events queue integration does not work with non-default event bus when using event bus arn
## Description
When using an event bus with a queue as the target, no events get passed through to the queue if the queue arn is used as the `EventBusName` parameter.

## Reproduction steps

```Python
import json

import boto3
from moto import mock_events, mock_sqs
from moto.core import ACCOUNT_ID


@mock_events
@mock_sqs
def test_queue_integration():
    # given
    client_events = boto3.client("events", "eu-central-1")
    client_sqs = boto3.client("sqs", region_name="eu-central-1")

    event_bus_arn = client_events.create_event_bus(Name="mock")["EventBusArn"]
    rule_name = "test-rule"
    queue_url = client_sqs.create_queue(QueueName="test-queue")["QueueUrl"]
    queue_arn = client_sqs.get_queue_attributes(
        QueueUrl=queue_url, AttributeNames=["QueueArn"]
    )["Attributes"]["QueueArn"]
    client_events.put_rule(
        Name=rule_name,
        EventPattern=json.dumps({"account": [ACCOUNT_ID]}),
        State="ENABLED",
        EventBusName=event_bus_arn,
    )
    client_events.put_targets(
        Rule=rule_name,
        Targets=[{"Id": "sqs", "Arn": queue_arn}],
        EventBusName=event_bus_arn
    )

    # when
    client_events.put_events(
        Entries=[
            {
                "Source": "source",
                "DetailType": "type",
                "Detail": json.dumps({"key": "value"}),
                "EventBusName": event_bus_arn
            }
        ],
    )

    # then
    response = client_sqs.receive_message(QueueUrl=queue_url)
    assert len(response["Messages"]) == 1

```

## Expected behaviour
The test passes (it does with no event bus specified)

## Actual behaviour
The test fails

```bash
collected 1 item                                                                                                                                                                                                                      

moto_test.py F                                                                                                                                                                                                                  [100%]

============================================================================================================== FAILURES ===============================================================================================================
_______________________________________________________________________________________________________ test_queue_integration ________________________________________________________________________________________________________

    @mock_events
    @mock_sqs
    def test_queue_integration():
        # given
        client_events = boto3.client("events", "eu-central-1")
        client_sqs = boto3.client("sqs", region_name="eu-central-1")
    
        event_bus_arn = client_events.create_event_bus(Name="mock")["EventBusArn"]
        rule_name = "test-rule"
        queue_url = client_sqs.create_queue(QueueName="test-queue")["QueueUrl"]
        queue_arn = client_sqs.get_queue_attributes(
            QueueUrl=queue_url, AttributeNames=["QueueArn"]
        )["Attributes"]["QueueArn"]
        client_events.put_rule(
            Name=rule_name,
            EventPattern=json.dumps({"account": [ACCOUNT_ID]}),
            State="ENABLED",
            EventBusName=event_bus_arn,
        )
        client_events.put_targets(
            Rule=rule_name,
            Targets=[{"Id": "sqs", "Arn": queue_arn}],
            EventBusName=event_bus_arn
        )
    
        # when
        client_events.put_events(
            Entries=[
                {
                    "Source": "source",
                    "DetailType": "type",
                    "Detail": json.dumps({"key": "value"}),
                    "EventBusName": event_bus_arn
                }
            ],
        )
    
        # then
        response = client_sqs.receive_message(QueueUrl=queue_url)
>       assert len(response["Messages"]) == 1
E       KeyError: 'Messages'

moto_test.py:47: KeyError
======================================================================================================= short test summary info =======================================================================================================
FAILED moto_test.py::test_queue_integration - KeyError: 'Messages'
========================================================================================================== 1 failed in 1.11s ==========================================================================================================
```

## moto version

2.0.7 installed via pip

## Potential solution

in `events.models.py`  change the `Rule` constructor to

```Python
def __init__(self, name, region_name, **kwargs): 
    self.name = name
    self.region_name = region_name
    self.event_pattern = EventPattern(kwargs.get("EventPattern"))
    self.schedule_exp = kwargs.get("ScheduleExpression")
    self.state = kwargs.get("State") or "ENABLED"
    self.description = kwargs.get("Description") 
    self.role_arn = kwargs.get("RoleArn")
    self.managed_by = kwargs.get("ManagedBy")  # can only be set by AWS services
    self.event_bus_name = kwargs.get("EventBusName").split("/")[-1] # <<---- CHANGE HERE
    self.created_by = ACCOUNT_ID
    self.targets = []
```

which will allow the if statement on line 103 to pass
```Python
event_bus_name = event_bus_name.split("/")[-1]
if event_bus_name != self.event_bus_name:  
    return
```
This if statement is currently evaluating to false since the member variable is set to the ARN but the variable is set to the actual name.


I can raise a PR for this if the solution is accepted :) 


Discussion:
On a related note (happy to raise another ticket if need be) this snippet requires the `docker` package to run, but it doesn't seem to be in `install_requires` of `setup.py` so when I install moto, it's not pulling in docker and the test doesn't run. Wondering if I'm missing a step or if docker should be a required package.
Hi @jamesTait-jt, thanks for raising this! Looks like your proposed solution is the simplest implementation, so a PR would be very welcome.

Re docker: How are you installing moto? As of 2.x, it's required to specify which services you're using: `pip install moto[sqs,events]`. 
Specifying the SQS-service should install docker as well. See this ticket for more info: #3722 


Resolving patch:
diff --git a/moto/events/models.py b/moto/events/models.py
--- a/moto/events/models.py
+++ b/moto/events/models.py
@@ -97,7 +97,7 @@ def remove_targets(self, ids):
 
     def send_to_targets(self, event_bus_name, event):
         event_bus_name = event_bus_name.split("/")[-1]
-        if event_bus_name != self.event_bus_name:
+        if event_bus_name != self.event_bus_name.split("/")[-1]:
             return
 
         if not self.event_pattern.matches_event(event):


Test patch:
diff --git a/tests/test_events/test_events_integration.py b/tests/test_events/test_events_integration.py
--- a/tests/test_events/test_events_integration.py
+++ b/tests/test_events/test_events_integration.py
@@ -206,3 +206,48 @@ def test_send_to_sqs_queue():
     body["region"].should.equal("eu-central-1")
     body["resources"].should.be.empty
     body["detail"].should.equal({"key": "value"})
+
+
+@mock_events
+@mock_sqs
+def test_send_to_sqs_queue_with_custom_event_bus():
+    # given
+    client_events = boto3.client("events", "eu-central-1")
+    client_sqs = boto3.client("sqs", region_name="eu-central-1")
+
+    event_bus_arn = client_events.create_event_bus(Name="mock")["EventBusArn"]
+    rule_name = "test-rule"
+    queue_url = client_sqs.create_queue(QueueName="test-queue")["QueueUrl"]
+    queue_arn = client_sqs.get_queue_attributes(
+        QueueUrl=queue_url, AttributeNames=["QueueArn"]
+    )["Attributes"]["QueueArn"]
+    client_events.put_rule(
+        Name=rule_name,
+        EventPattern=json.dumps({"account": [ACCOUNT_ID]}),
+        State="ENABLED",
+        EventBusName=event_bus_arn,
+    )
+    client_events.put_targets(
+        Rule=rule_name,
+        Targets=[{"Id": "sqs", "Arn": queue_arn}],
+        EventBusName=event_bus_arn,
+    )
+
+    # when
+    client_events.put_events(
+        Entries=[
+            {
+                "Source": "source",
+                "DetailType": "type",
+                "Detail": json.dumps({"key": "value"}),
+                "EventBusName": event_bus_arn,
+            }
+        ],
+    )
+
+    # then
+    response = client_sqs.receive_message(QueueUrl=queue_url)
+    assert len(response["Messages"]) == 1
+
+    body = json.loads(response["Messages"][0]["Body"])
+    body["detail"].should.equal({"key": "value"})