def test_cleanup_should_remove_old_message(self):
     message_body = (
         '{ '
         '"status": "UPDATE_COMPLETE", '
         '"timestamp": "2015-11-24T13:14:16.575Z", '
         '"stackName": "my-teststack", '
         '"message": "User Initiated", '
         '"emitter": "cloudformation", '
         '"resourceType": "AWS::CloudFormation::Stack"}')
     sqs = boto3.resource('sqs')
     queue = sqs.create_queue(QueueName='BACK_CHANNEL')
     queue.send_message(MessageBody=message_body)
     queue.send_message(MessageBody=message_body)
     cleanup('BACK_CHANNEL', 30, 'my-teststack', 'eu-west-1')
    def send_update_message(self, invoker_role):
        credentials = self.assume_role(invoker_role)
        credentials_set(credentials)
        crassus_input_topic_arn = self.get_stack_output(
            self.crassus_stack_name, 'inputSnsTopicARN')
        back_channel_url = self.get_stack_output(
            self.crassus_stack_name, 'outputSqsQueue')
        run_seconds = 10
        cleanup(
            back_channel_url, run_seconds, self.crassus_stack_name,
            REGION_NAME)
        result = notify(
            self.app_stack_name, 'dockerImageVersion=40',
            crassus_input_topic_arn, REGION_NAME)

        logger.info(
            'published update message to topic: {0}, message: {1}, got '
            'message_id: {2}'.format(
                crassus_input_topic_arn, 'dockerImageVersion=40', result
            ))