예제 #1
0
 def test_kinesis(self, set_environment):
     kinesis_streams = fixtures.KINESIS
     queue = Queue(type=QueueType.KINESIS,
                   path="FOO",
                   name=kinesis_streams[0])
     fixture = {"path": queue.path, "kwargs": {}}
     put_record(queue=queue, record=fixture)
예제 #2
0
def put_record(queue: Queue, record: dict):
    if queue.type == QueueType.KINESIS:
        return kinesis.put_record(stream_name=queue.name, data=record)
    if queue.type == QueueType.SQS:
        if not queue.url:
            queue.url = sqs.get_queue_url(queue.name)
        try:
            return sqs.put_message(queue_url=queue.url, data=record)
        except Exception as e:
            raise lpipe.exceptions.FailCatastrophically(
                f"Failed to send message to {queue}") from e
예제 #3
0
 def test_fail_to_send(self, set_environment):
     queue = Queue(type=QueueType.SQS, path="FOO", url="badqueue")
     fixture = {"path": queue.path, "kwargs": {}}
     with pytest.raises(exceptions.FailCatastrophically):
         put_record(queue=queue, record=fixture)
예제 #4
0
 def test_sqs_fail_to_discover_url(self, set_environment):
     queue = Queue(type=QueueType.SQS, path="FOO", name="badqueue")
     fixture = {"path": queue.path, "kwargs": {}}
     with pytest.raises(botocore.exceptions.ClientError):
         put_record(queue=queue, record=fixture)
예제 #5
0
 def test_sqs_by_name(self, set_environment):
     sqs_queues = fixtures.SQS
     queue_name = sqs_queues[0]
     queue = Queue(type=QueueType.SQS, path="FOO", name=queue_name)
     fixture = {"path": queue.path, "kwargs": {}}
     put_record(queue=queue, record=fixture)
예제 #6
0
 def test_sqs_by_url(self, set_environment):
     sqs_queues = fixtures.SQS
     queue_url = get_queue_url(sqs_queues[0])
     queue = Queue(type=QueueType.SQS, path="FOO", url=queue_url)
     fixture = {"path": queue.path, "kwargs": {}}
     put_record(queue=queue, record=fixture)
예제 #7
0
 def test_queue_payload(self, fixture_name, fixture):
     q = Queue(**fixture)
     Payload(queue=q, kwargs={"foo": "bar"}).validate()
예제 #8
0
def test_queue(fixture_name, fixture):
    q = Queue(QueueType.SQS, "FOO", **fixture)
    assert q