• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_discovery / 3823446b-c57e-4abf-8330-d3cff9d77076

pending completion
3823446b-c57e-4abf-8330-d3cff9d77076

Pull #382

circleci

Hector Correa
When importing dataspace records, skip those that have matching records already imported from PDC Describe
Pull Request #382: Give priority to PDC Describe records when indexing records

5 of 5 new or added lines in 1 file covered. (100.0%)

1714 of 1932 relevant lines covered (88.72%)

102.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/spec/lib/dspace_research_data_harvester_spec.rb
1
# frozen_string_literal: true
2

3
RSpec.describe DspaceResearchDataHarvester do
1✔
4
  let(:rdh) { described_class.new }
3✔
5

6
  it "has a list of collections to index" do
1✔
7
    expect(rdh.collections_to_index.count).to eq 33
1✔
8
  end
9

10
  it "has a convenience method for indexing all collections" do
1✔
11
    expect_any_instance_of(described_class).to receive(:harvest).exactly(33).times
1✔
12
    described_class.harvest(true)
1✔
13
  end
14

15
  context "harvesting a collection" do
1✔
16
    let(:csv_data) do
1✔
17
      {
1✔
18
        "ParentCommunity" => "Princeton Plasma Physics Laboratory",
19
        "Community" => "Spherical Torus",
20
        "CollectionName" => "NSTX",
21
        "Handle" => "88435/dsp018p58pg29j",
22
        "CollectionID" => "1282",
23
        "ItemCount" => "33",
24
        nil => nil
25
      }
26
    end
27
    let(:csv_row) { CSV::Row.new(csv_data.keys, csv_data.values) }
2✔
28
    let(:rdc) { ResearchDataCollection.new(csv_row) }
2✔
29
    let(:collection_1282_xml) { File.read(File.join(fixture_path, 'spherical_torus.xml')) }
2✔
30

31
    before do
1✔
32
      Blacklight.default_index.connection.delete_by_query("*:*")
1✔
33
      Blacklight.default_index.connection.commit
1✔
34

35
      stub_request(:get, "https://dataspace-dev.princeton.edu/rest/collections/1282/items?expand=all&limit=100&offset=0")
1✔
36
        .with(
37
          headers: {
38
            'Accept' => 'application/xml'
39
          }
40
        )
41
        .to_return(status: 200, body: collection_1282_xml, headers: {})
42
    end
43

44
    it "retrieves data from dspace and indexes it to solr" do
1✔
45
      response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
1✔
46
      expect(response["response"]["numFound"]).to eq 0
1✔
47

48
      rdh.harvest(rdc)
1✔
49

50
      response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
×
51
      expect(response["response"]["numFound"]).to eq 32
×
52
    end
53
  end
54
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc