<commit_before>require "spec_helper"

describe Echo::ClientMiddleware::AtomDatasetMiddleware do
  let(:middleware) { Echo::ClientMiddleware::AtomDatasetMiddleware.new }

  context 'when given parsed Atom dataset data' do
    let(:env) do
      { body: {
          'feed' => {
            'title' => 'ECHO dataset metadata',
            'entry' => [
                        {
                          'id' => 'id1',
                          'dataset_id' => 'dataset_id1',
                          'summary' => 'summary1',
                          'updated' => 'updated1',
                          'short_name' => 'short_name1',
                          'version_id' => '',
                          'data_center' => '',
                          'archive_center' => '',
                          'processing_level_id' => '',
                          'time_start' => '',
                          'time_end' => '',
                          'links' => '',
                          'boxes' => '',
                          'points' => '',
                          'dif_ids' => '',
                          'online_access_flag' => '',
                          'browse_flag' => '',
                        },
                        {
                          'id' => 'id2'
                        }
                       ]
          }
        }
      }
    end

    it 'updates the parsed body to contain a list of datasets' do
      original_body = env[:body]
      middleware.process_response(env)
      datasets = env[:body]
      expect(datasets).to be_instance_of(Array)
      expect(datasets.size).to eq(2)
      expect(datasets[0].as_json).to eq(original_body["feed"]["entry"][0])
    end

  end

  it 'does not operate on response strings' do
    env = { body: '{"feed":{"title":"ECHO dataset metadata"}}' }
    expect(middleware.parse_response?(env)).to be_false
  end

  it 'does not operate on hashes containing parsed Atom granule data' do
    env = { body: { 'feed' => { 'title' => 'ECHO granule metadata' } } }
    expect(middleware.parse_response?(env)).to be_false
  end
end
<commit_msg>fixed a failing atom middleware spec<commit_after>require "spec_helper"

describe Echo::ClientMiddleware::AtomDatasetMiddleware do
  let(:middleware) { Echo::ClientMiddleware::AtomDatasetMiddleware.new }

  context 'when given parsed Atom dataset data' do
    let(:env) do
      { body: {
          'feed' => {
            'title' => 'ECHO dataset metadata',
            'entry' => [
                        {
                          'id' => 'id1',
                          'dataset_id' => 'dataset_id1',
                          'summary' => 'summary1',
                          'updated' => 'updated1',
                          'short_name' => 'short_name1',
                          'version_id' => '',
                          'data_center' => '',
                          'archive_center' => '',
                          'processing_level_id' => '',
                          'time_start' => '',
                          'time_end' => '',
                          'links' => '',
                          'boxes' => nil,
                          'points' => nil,
                          'polygons' => nil,
                          'lines' => nil,
                          'dif_ids' => '',
                          'online_access_flag' => '',
                          'browse_flag' => '',
                        },
                        {
                          'id' => 'id2'
                        }
                       ]
          }
        }
      }
    end

    it 'updates the parsed body to contain a list of datasets' do
      original_body = env[:body]
      middleware.process_response(env)
      datasets = env[:body]
      expect(datasets).to be_instance_of(Array)
      expect(datasets.size).to eq(2)
      expect(datasets[0].as_json).to eq(original_body["feed"]["entry"][0])
    end

  end

  it 'does not operate on response strings' do
    env = { body: '{"feed":{"title":"ECHO dataset metadata"}}' }
    expect(middleware.parse_response?(env)).to be_false
  end

  it 'does not operate on hashes containing parsed Atom granule data' do
    env = { body: { 'feed' => { 'title' => 'ECHO granule metadata' } } }
    expect(middleware.parse_response?(env)).to be_false
  end
end

{'fraction_non_alphanumeric': 0.12776752767527674, 'fraction_numerical': 0.004151291512915129, 'mean_word_length': 1.268305439330544, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 51, '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': '6645229', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1156, 'n_words': 237}