|
3 | 3 | require 'spec_helper' |
4 | 4 | require 'tempfile' |
5 | 5 |
|
| 6 | +# rubocop:disable Metrics/BlockLength |
6 | 7 | describe BerkeleyLibrary::SftpHandler::Downloader::Lbnl do |
7 | 8 | its(:default_host) { is_expected.to eq 'ncc-1701.lbl.gov' } |
8 | 9 | its(:default_username) { is_expected.to eq 'ucblib' } |
|
25 | 26 | Timecop.unfreeze |
26 | 27 | end |
27 | 28 |
|
28 | | - it "downloads this week's file" do |
| 29 | + it 'downloads this week\'s file' do |
29 | 30 | expect(sftp_session) |
30 | 31 | .to receive(:download!) |
31 | 32 | .with(todays_remote_path.to_s, Pathname.new("/opt/app/data/#{this_weeks_filename}").to_s) |
32 | 33 |
|
33 | 34 | subject.download! |
34 | 35 | end |
35 | 36 |
|
36 | | - it "downloads to an alternate local_dir" do |
| 37 | + it 'downloads to an alternate local_dir' do |
37 | 38 | local_dir = '/netapp/alma/lbnl_patrons' |
38 | 39 |
|
39 | 40 | expect(sftp_session) |
|
43 | 44 | subject.download!(local_dir: local_dir) |
44 | 45 | end |
45 | 46 |
|
46 | | - it "downloads a specific file" do |
| 47 | + it 'downloads a specific file' do |
47 | 48 | filename = 'lbnl_people_20220516.zip' |
48 | 49 | remote_path = Pathname.new(filename) |
49 | 50 | local_path = Pathname.new("/opt/app/data/#{filename}") |
|
56 | 57 | end |
57 | 58 | end |
58 | 59 |
|
59 | | - describe '#assert_file_not_processed!' do |
60 | | - it 'proceeds if processed file is absent' do |
61 | | - expect { subject.assert_file_not_processed!('/path/to/non-existent-file') }.not_to raise_error |
| 60 | + describe '#file_retrieved?' do |
| 61 | + it 'returns false if file was already retrieved or processed' do |
| 62 | + expect(subject.file_retrieved?('/path/to/non-existent-file')).to be(false) |
62 | 63 | end |
63 | 64 |
|
64 | | - it 'raises if processed file exists' do |
65 | | - f = Tempfile.new(['temp_file38348', '.old']) |
66 | | - expect { subject.assert_file_not_processed! f.path.gsub('.old', '') }.to raise_error RuntimeError |
| 65 | + it 'returns true if file was already retrieved' do |
| 66 | + f = Tempfile.new('temp_file38348') |
| 67 | + expect(subject.file_retrieved?(f)).to be(true) |
| 68 | + end |
| 69 | + |
| 70 | + it 'returns true if file was already processed' do |
| 71 | + f = Tempfile.new('temp_file38348.old') |
| 72 | + expect(subject.file_retrieved?(f)).to be(true) |
67 | 73 | end |
68 | 74 | end |
69 | 75 |
|
|
101 | 107 | end |
102 | 108 | end |
103 | 109 | end |
| 110 | +# rubocop:enable Metrics/BlockLength |
0 commit comments