<commit_before>require 'spec_helper'

describe "Hydrus collections" do
    
  shared_examples_for 'hydrus collection object' do | solr_doc_id |
    it "should have display_type of file" do
      resp = solr_response({'qt'=>'document', 'id'=>solr_doc_id, 'fl'=>'id,display_type', 'facet'=>false})
      resp.should include('display_type' => 'file')
    end
  end
  shared_examples_for 'hydrus item object' do | solr_doc_id |
    it "should have display_type of file" do
      resp = solr_response({'qt'=>'document', 'id'=>solr_doc_id, 'fl'=>'id,display_type', 'facet'=>false})
      resp.should include('display_type' => 'file')
    end
  end
  
  # tests for hydrus collections
  # coll_druid: the druid of the collection object
  # num_items: the number of items in this collection
  # display_types:  the expected value(s) of SW display_type field.  Can be String or Array of Strings
  # formats:  the expected value(s) of SW format field.  Can be String or Array of Strings
  # author_missing_ids: the ids of records missing searchable author.  nil, String, or Array of Strings
  # item_query_str:  the query string to retrieve items from this collection in a SW 'everything' search
  # item_druid:  the druid of an item expected to be retrieved with the query
  # num_results:  the item druid will be found within the first (n) of the search results
  shared_examples_for 'hydrus coll' do | coll_druid, num_items, display_types, formats, author_missing_ids, item_query_str, item_druid, num_results |
    it_behaves_like "all items in collection", coll_druid, num_items
    it_behaves_like "DOR collection object", coll_druid, coll_druid
    it_behaves_like "hydrus collection object", coll_druid
    it_behaves_like "DOR item objects", item_query_str, [item_druid], num_results, coll_druid
    it_behaves_like "hydrus item object", item_druid
    facet_query = "collection:#{coll_druid}"
    it_behaves_like 'expected display_type values', facet_query, display_types
    it_behaves_like 'expected format values', facet_query, formats
    it_behaves_like "date fields present", facet_query
    if author_missing_ids && author_missing_ids.size > 0
      it_behaves_like "author field present except", facet_query, author_missing_ids
    else
      it_behaves_like "author field present", facet_query
    end
    # as of 2014-03, there is no way to input language into Hydrus metadata, 
    # so language can't be required until that is fixed.
#    it_behaves_like "language", facet_query
  end

  context "Big Ideas" do
    # DATA FIXME:  is format 'Other' still best fit?
    it_behaves_like 'hydrus coll', 'xf112dv1419', 74, 'file', 'Other', nil, "alix personal", 'mq607rm1165', 3
  end
  context "engineering physics undergrad theses" do
    it_behaves_like 'hydrus coll', 'xv924ks7647', 3, 'file', "Thesis", nil, "deduceit", 'bg823wn2892', 3
  end
  context "engineering undergrad theses" do
    it_behaves_like 'hydrus coll', 'jg722zc0626', 35, 'file', 'Thesis', nil, "uclinux", 'ng517gq2855', 3
  end
  context "Folding@home" do
    it_behaves_like 'hydrus coll', 'cj269gn0736', 6, 'file', "Computer File", nil, "hp35 trajectory data", 'bd829sf1034', 3
  end
  context "Forum on Future of Scientific Publishing" do
    it_behaves_like 'hydrus coll', 'ck552zg2217', 14, 'file', 'Conference Proceedings', nil, "open access to manuscripts", 'fx147cs4847', 10
  end
  context "Hopkins Marine Station collection" do
    it_behaves_like 'hydrus coll', 'pn808wc6253', 7, 'file', "Computer File", ["fp045wx3019", "tt999fm2734", "gk364tm7562", "yb742ts0531"], "sea anemone distribution", 'fp045wx3019', 10
    facet_query = "collection:pn808wc6253"
    it_behaves_like "language", facet_query
  end
  context "<NAME> Earthquake Engineering Center Technical Report Series" do
    it_behaves_like 'hydrus coll', 'mz198fp9366', 162, 'file', "Book", ["dv756jr9637", "nh929nm1593"], "damage diagnosis algorithms", 'wg007jn8560', 5
    #it_behaves_like "language", facet_query # 157 recs missing language as of 2014-05-23
  end
  context "ME310 2013" do
    # DATA FIXME:  is format 'Other' still best fit?
    it_behaves_like 'hydrus coll', 'kq629sd5182', 8, 'file', "Other", nil, "audievolve", 'qt429km6702', 3
  end
  context "Physics Undergrad Theses" do
    it_behaves_like 'hydrus coll', 'ds247vz0452', 17, 'file', "Thesis", nil, "scanning squid", 'gh325bb5942', 3
  end
  context "Preserving Virtual Worlds" do
    it_behaves_like 'hydrus coll', 'sn446tz2204', 8, 'file', "Computer File", ['xy157wz5444', 'rd383mp8260'], "star raiders", 'pp060nc9006', 3
  end
  context "Research Datasets for Image, Video, and Multimedia Systems Group @ Stanford" do
    it_behaves_like 'hydrus coll', 'cm018rf5314', 8, 'file', "Computer File", nil, "Stanford Streaming Mobile Augmented Reality Dataset", 'ph459zk5920', 5
  end
  context "Serial section electron microscopy data for Nanoscale organization of the MEC-4 DEG/ENaC sensory mechanotransduction channel in Caenorhabditis elegans touch receptor neurons" do
    it_behaves_like 'hydrus coll', 'cv355cw2458', 2, 'file', "Computer File", nil, "immuno electron microscopy", 'zb423jg0099', 10
  end
  context "Serial section electron microscopy data for Posttranslational acetylation of alpha tubulin constrains protofilament number in native microtubules" do
    it_behaves_like 'hydrus coll', 'sc642pw6867', 8, "file", "Computer File", nil, "touch receptor neurons", 'qg053ym5844', 10
  end
  context "Stanford Research Data" do
    it_behaves_like 'hydrus coll', 'md919gh6774', 6, 'file', "Computer File", nil, "high angular resolution", 'yx282xq2090', 3
  end
  context "SUL staff publications" do
    it_behaves_like 'hydrus coll', 'hn730ks3626', 4, 'file', "Journal/Periodical", nil, "academy unbound", 'bd701dh8028', 3
  end<commit_msg>changing expected number of items for Undergraduate Theses, Department of Physics from 17 to 18<commit_after>require 'spec_helper'

describe "Hydrus collections" do
    
  shared_examples_for 'hydrus collection object' do | solr_doc_id |
    it "should have display_type of file" do
      resp = solr_response({'qt'=>'document', 'id'=>solr_doc_id, 'fl'=>'id,display_type', 'facet'=>false})
      resp.should include('display_type' => 'file')
    end
  end
  shared_examples_for 'hydrus item object' do | solr_doc_id |
    it "should have display_type of file" do
      resp = solr_response({'qt'=>'document', 'id'=>solr_doc_id, 'fl'=>'id,display_type', 'facet'=>false})
      resp.should include('display_type' => 'file')
    end
  end
  
  # tests for hydrus collections
  # coll_druid: the druid of the collection object
  # num_items: the number of items in this collection
  # display_types:  the expected value(s) of SW display_type field.  Can be String or Array of Strings
  # formats:  the expected value(s) of SW format field.  Can be String or Array of Strings
  # author_missing_ids: the ids of records missing searchable author.  nil, String, or Array of Strings
  # item_query_str:  the query string to retrieve items from this collection in a SW 'everything' search
  # item_druid:  the druid of an item expected to be retrieved with the query
  # num_results:  the item druid will be found within the first (n) of the search results
  shared_examples_for 'hydrus coll' do | coll_druid, num_items, display_types, formats, author_missing_ids, item_query_str, item_druid, num_results |
    it_behaves_like "all items in collection", coll_druid, num_items
    it_behaves_like "DOR collection object", coll_druid, coll_druid
    it_behaves_like "hydrus collection object", coll_druid
    it_behaves_like "DOR item objects", item_query_str, [item_druid], num_results, coll_druid
    it_behaves_like "hydrus item object", item_druid
    facet_query = "collection:#{coll_druid}"
    it_behaves_like 'expected display_type values', facet_query, display_types
    it_behaves_like 'expected format values', facet_query, formats
    it_behaves_like "date fields present", facet_query
    if author_missing_ids && author_missing_ids.size > 0
      it_behaves_like "author field present except", facet_query, author_missing_ids
    else
      it_behaves_like "author field present", facet_query
    end
    # as of 2014-03, there is no way to input language into Hydrus metadata, 
    # so language can't be required until that is fixed.
#    it_behaves_like "language", facet_query
  end

  context "Big Ideas" do
    # DATA FIXME:  is format 'Other' still best fit?
    it_behaves_like 'hydrus coll', 'xf112dv1419', 74, 'file', 'Other', nil, "alix personal", 'mq607rm1165', 3
  end
  context "engineering physics undergrad theses" do
    it_behaves_like 'hydrus coll', 'xv924ks7647', 3, 'file', "Thesis", nil, "deduceit", 'bg823wn2892', 3
  end
  context "engineering undergrad theses" do
    it_behaves_like 'hydrus coll', 'jg722zc0626', 35, 'file', 'Thesis', nil, "uclinux", 'ng517gq2855', 3
  end
  context "Folding@home" do
    it_behaves_like 'hydrus coll', 'cj269gn0736', 6, 'file', "Computer File", nil, "hp35 trajectory data", 'bd829sf1034', 3
  end
  context "Forum on Future of Scientific Publishing" do
    it_behaves_like 'hydrus coll', 'ck552zg2217', 14, 'file', 'Conference Proceedings', nil, "open access to manuscripts", 'fx147cs4847', 10
  end
  context "Hopkins Marine Station collection" do
    it_behaves_like 'hydrus coll', 'pn808wc6253', 7, 'file', "Computer File", ["fp045wx3019", "tt999fm2734", "gk364tm7562", "yb742ts0531"], "sea anemone distribution", 'fp045wx3019', 10
    facet_query = "collection:pn808wc6253"
    it_behaves_like "language", facet_query
  end
  context "<NAME> Earthquake Engineering Center Technical Report Series" do
    it_behaves_like 'hydrus coll', 'mz198fp9366', 162, 'file', "Book", ["dv756jr9637", "nh929nm1593"], "damage diagnosis algorithms", 'wg007jn8560', 5
    #it_behaves_like "language", facet_query # 157 recs missing language as of 2014-05-23
  end
  context "ME310 2013" do
    # DATA FIXME:  is format 'Other' still best fit?
    it_behaves_like 'hydrus coll', 'kq629sd5182', 8, 'file', "Other", nil, "audievolve", 'qt429km6702', 3
  end
  context "Physics Undergrad Theses" do
    it_behaves_like 'hydrus coll', 'ds247vz0452', 18, 'file', "Thesis", nil, "scanning squid", 'gh325bb5942', 3
  end
  context "Preserving Virtual Worlds" do
    it_behaves_like 'hydrus coll', 'sn446tz2204', 8, 'file', "Computer File", ['xy157wz5444', 'rd383mp8260'], "star raiders", 'pp060nc9006', 3
  end
  context "Research Datasets for Image, Video, and Multimedia Systems Group @ Stanford" do
    it_behaves_like 'hydrus coll', 'cm018rf5314', 8, 'file', "Computer File", nil, "Stanford Streaming Mobile Augmented Reality Dataset", 'ph459zk5920', 5
  end
  context "Serial section electron microscopy data for Nanoscale organization of the MEC-4 DEG/ENaC sensory mechanotransduction channel in Caenorhabditis elegans touch receptor neurons" do
    it_behaves_like 'hydrus coll', 'cv355cw2458', 2, 'file', "Computer File", nil, "immuno electron microscopy", 'zb423jg0099', 10
  end
  context "Serial section electron microscopy data for Posttranslational acetylation of alpha tubulin constrains protofilament number in native microtubules" do
    it_behaves_like 'hydrus coll', 'sc642pw6867', 8, "file", "Computer File", nil, "touch receptor neurons", 'qg053ym5844', 10
  end
  context "Stanford Research Data" do
    it_behaves_like 'hydrus coll', 'md919gh6774', 6, 'file', "Computer File", nil, "high angular resolution", 'yx282xq2090', 3
  end
  context "SUL staff publications" do
    it_behaves_like 'hydrus coll', 'hn730ks3626', 4, 'file', "Journal/Periodical", nil, "academy unbound", 'bd701dh8028', 3
  end
{'fraction_non_alphanumeric': 0.10106474325948824, 'fraction_numerical': 0.05890434483942985, 'mean_word_length': 4.927226463104326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '208495', 'n_tokens_mistral': 4429, 'n_tokens_neox': 3805, 'n_words': 1275}