<commit_before># tests for required fields given a facet query
shared_examples_for 'have required fields:' do | facet_query |
  it "druid" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-druid:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "access_facet = Online" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-access_facet:Online"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "format" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-format:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "display_type" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-display_type:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "sortable title" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-title_sort:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "searchabe short title" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-title_245a_search:*"]})
    resp.should_not have_documents
  end
  it "searchable full title" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-title_245_search:*"]})
    resp.should_not have_documents
  end
  it "sortable pub date" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-pub_date_sort:*"]})
    resp.should_not have_documents
  end
  it "date slider dates" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-pub_year_tisim:*"]})
    resp.should_not have_documents
  end
end


# tests for all items in a collection
# coll_id = collection record id (e.g. a ckey or druid)
# num_exp = the number of items expected in the collection
shared_examples_for 'all items in collection' do | coll_id, num_exp |
  it "should be the expected number" do
    resp = solr_resp_doc_ids_only({'fq'=>"collection:#{coll_id}", 'rows'=>'0'})<commit_msg>add tests for VALID format and display_type values<commit_after># tests for required fields given a facet query
shared_examples_for 'have required fields:' do | facet_query |
  it "druid" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-druid:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "access_facet = Online" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-access_facet:Online"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "format" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-format:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "valid format value" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query,
      # commented out lines are because gdor has no records in those formats
                                          '-format:Book',
                                          '-format:"Computer File"',
#                                          '-format:"Conference Proceedings"',
#                                          '-format:Database',
                                          '-format:Image',
                                          '-format:"Journal/Periodical"',
                                          '-format:"Manuscript/Archive"',
                                          '-format:"Map/Globe"',
#                                          '-format:Microformat',
#                                          '-format:"Music - Recording"',
#                                          '-format:"Music - Score"',
#                                          '-format:Newspaper',
                                          '-format:Other',
#                                          '-format:"Sound Recording"',
                                          '-format:Thesis',
                                          '-format:Video'
                                          ]})
    resp.should_not have_documents
  end
  it "display_type" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-display_type:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "valid display_type value" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query,
                                          '-display_type:collection',
                                          '-display_type:hydrus_collection',
                                          '-display_type:hydrus_object',
                                          '-display_type:image',
                                          '-display_type:map'
                                          ]})
    resp.should_not have_documents
  end
  it "sortable title" do
    resp = solr_resp_doc_ids_only({'fq'=>[facet_query, "-title_sort:*"], 'rows'=>'0'})
    resp.should_not have_documents
  end
  it "searchabe short title" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-title_245a_search:*"]})
    resp.should_not have_documents
  end
  it "searchable full title" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-title_245_search:*"]})
    resp.should_not have_documents
  end
  it "sortable pub date" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-pub_date_sort:*"]})
    resp.should_not have_documents
  end
  it "date slider dates" do
    resp = solr_resp_doc_ids_only({'fq'=> [facet_query, "-pub_year_tisim:*"]})
    resp.should_not have_documents
  end
end


# tests for all items in a collection
# coll_id = collection record id (e.g. a ckey or druid)
# num_exp = the number of items expected in the collection
shared_examples_for 'all items in collection' do | coll_id, num_exp |
  it "should be the expected number" do
    resp = solr_resp_doc_ids_only({'fq'=>"collection:#{coll_id}", 'rows'=>'0'})
{'fraction_non_alphanumeric': 0.12340348983630149, 'fraction_numerical': 0.004317323259579061, 'mean_word_length': 2.2231884057971016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '948643', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1664, 'n_words': 382}