<commit_before>require 'spec_helper'
require 'freddy'

class Messaging::Consumer
  def create_queue(queue_name)
    #want to auto_delete queues while testing
    @channel.queue(queue_name, auto_delete: true)
  end
end

class Messaging::Request
  def create_response_queue
    #exclusive queues are deleted when the consumer disconnects,
    #auto_delete doesn't work when there are no requests
    @channel.queue("", exclusive: true, auto_delete: true)
  end
end

def random_destination
  SecureRandom.hex
end

def default_sleep
  sleep 0.05
end

def deliver(custom_destination = destination)
  freddy.deliver custom_destination, payload
  default_sleep
end

def default_let
  let(:freddy) { Freddy.new }
  let(:consumer) { Messaging::Consumer.new }
  let(:producer) { Messaging::Producer.new }
  let(:destination) { random_destination }
  let(:payload) { {pay: 'load'} }
end

logger = Logger.new(STDOUT).tap { |l| l.level = Logger::ERROR }
Freddy.setup(logger, host: 'localhost', port: 5672, user: 'guest', pass: '<PASSWORD>')<commit_msg>response queue is exclusive already, making it auto_delete for tests accomplishes nothing<commit_after>require 'spec_helper'
require 'freddy'

class Messaging::Consumer
  def create_queue(queue_name)
    #want to auto_delete queues while testing
    @channel.queue(queue_name, auto_delete: true)
  end
end

def random_destination
  SecureRandom.hex
end

def default_sleep
  sleep 0.05
end

def deliver(custom_destination = destination)
  freddy.deliver custom_destination, payload
  default_sleep
end

def default_let
  let(:freddy) { Freddy.new }
  let(:consumer) { Messaging::Consumer.new }
  let(:producer) { Messaging::Producer.new }
  let(:destination) { random_destination }
  let(:payload) { {pay: 'load'} }
end

logger = Logger.new(STDOUT).tap { |l| l.level = Logger::ERROR }
Freddy.setup(logger, host: 'localhost', port: 5672, user: 'guest', pass: '<PASSWORD>')
{'fraction_non_alphanumeric': 0.107386066003143, 'fraction_numerical': 0.007333682556312206, 'mean_word_length': 5.221498371335505, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '900493', 'n_tokens_mistral': 629, 'n_tokens_neox': 606, 'n_words': 165}