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

pulibrary / bibdata / ec60d377-8954-419a-a945-5bdc4a0ed7e0

04 Jan 2025 06:54PM UTC coverage: 92.035% (+0.08%) from 91.952%
ec60d377-8954-419a-a945-5bdc4a0ed7e0

Pull #2586

circleci

web-flow
Merge branch 'main' into refactor_unzip_process
Pull Request #2586: Refactor unzipping and xml file cleanup

51 of 51 new or added lines in 3 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

3432 of 3729 relevant lines covered (92.04%)

370.88 hits per line

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

92.0
/app/models/scsb/partner_updates/full.rb
1
module Scsb
1✔
2
  class PartnerUpdates
1✔
3
    class Full < Update
1✔
4
      def initialize(dump:, dump_file_type:, timestamp: DateTime.now.to_time)
1✔
5
        super
3✔
6
      end
7

8
      def self.validate_csv(dump_id, file, institution)
1✔
9
        matches_expected_collections = false
20✔
10
        raise StandardError, "No metadata files found matching #{institution}" unless file
20✔
11

12
        csv = CSV.read(file, headers: true)
18✔
13
        group_ids = csv['Collection Group Id(s)'].first
18✔
14
        matches_expected_collections = group_ids == '1*2*5*6'
18✔
15
        filename = File.basename(file)
18✔
16
        scsb_file_dir = ENV['SCSB_FILE_DIR']
18✔
17
        destination_filepath = "#{scsb_file_dir}/#{filename}"
18✔
18
        FileUtils.move(file, destination_filepath)
18✔
19
        Dump.attach_dump_file(dump_id, destination_filepath, :recap_records_full_metadata)
18✔
20
        File.unlink(destination_filepath) if File.exist?(destination_filepath)
18✔
21
        unless matches_expected_collections
18✔
22
          raise StandardError, "Metadata file indicates that dump for #{institution} does not include the correct Group IDs, not processing. Group ids: #{group_ids}"
1✔
23
        end
24

25
        matches_expected_collections
17✔
26
      end
27

28
      def download_full_file(file_filter)
1✔
UNCOV
29
        prefix = ENV['SCSB_S3_PARTNER_FULLS'] || 'data-exports/PUL/MARCXml/Full'
×
UNCOV
30
        @s3_bucket.download_recent(prefix:, output_directory: @update_directory, file_filter:)
×
31
      end
32

33
      def self.download_full_file(institution, extension)
1✔
34
        Scsb::S3Bucket.partner_transfer_client.download_recent(
33✔
35
          prefix: ENV['SCSB_S3_PARTNER_FULLS'] || 'data-exports/PUL/MARCXml/Full',
36
          output_directory: ENV['SCSB_PARTNER_UPDATE_DIRECTORY'] || '/tmp/updates',
37
          file_filter: /#{institution}.*\.#{extension}/
38
        )
39
      end
40
    end
41
  end
42
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