Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 6; |
20 |
use Test::More tests => 7; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
|
22 |
|
23 |
use Koha::Database; |
23 |
use Koha::Database; |
Lines 128-138
Nature Astronomy 2397-3366 2017-01 1 1 https://www.nature.com/natastron 4bb
Link Here
|
128 |
}; |
128 |
}; |
129 |
|
129 |
|
130 |
my ( $column_headers, $lines ) = Koha::BackgroundJob::ImportKBARTFile::read_file($file); |
130 |
my ( $column_headers, $lines ) = Koha::BackgroundJob::ImportKBARTFile::read_file($file); |
|
|
131 |
my @invalid_columns; |
131 |
|
132 |
|
132 |
my $title_from_line1 = |
133 |
my $title_from_line1 = |
133 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[0], $column_headers ); |
134 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[0], $column_headers, \@invalid_columns ); |
134 |
my $title_from_line2 = |
135 |
my $title_from_line2 = |
135 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[1], $column_headers ); |
136 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[1], $column_headers, \@invalid_columns ); |
|
|
137 |
|
138 |
my $line1_match = { |
139 |
'coverage_depth' => 'fulltext', |
140 |
'date_monograph_published_print' => '', |
141 |
'date_first_issue_online' => '2015-01', |
142 |
'date_last_issue_online' => '', |
143 |
'coverage_notes' => 'Hybrid (Open Choice)', |
144 |
'first_editor' => '', |
145 |
'date_monograph_published_online' => '', |
146 |
'preceding_publication_title_id' => '', |
147 |
'num_last_issue_online' => '', |
148 |
'embargo_info' => '', |
149 |
'access_type' => 'P', |
150 |
'num_first_issue_online' => '1', |
151 |
'online_identifier' => '2055-0278', |
152 |
'title_url' => 'https://www.nature.com/nplants', |
153 |
'monograph_volume' => '', |
154 |
'first_author' => '', |
155 |
'parent_publication_title_id' => '', |
156 |
'num_last_vol_online' => '', |
157 |
'publication_title' => 'Nature Plants', |
158 |
'num_first_vol_online' => '1', |
159 |
'print_identifier' => '', |
160 |
'publisher_name' => 'Nature Publishing Group UK', |
161 |
'title_id' => '4aaa7', |
162 |
'publication_type' => 'serial', |
163 |
'monograph_edition' => '' |
164 |
}; |
165 |
my $line2_match = { |
166 |
'date_monograph_published_online' => '', |
167 |
'num_first_vol_online' => '1', |
168 |
'num_last_issue_online' => '', |
169 |
'preceding_publication_title_id' => '', |
170 |
'title_url' => 'https://www.nature.com/natastron', |
171 |
'online_identifier' => '2397-3366', |
172 |
'print_identifier' => '', |
173 |
'num_last_vol_online' => '', |
174 |
'embargo_info' => '', |
175 |
'parent_publication_title_id' => '', |
176 |
'publisher_name' => 'Nature Publishing Group UK', |
177 |
'date_first_issue_online' => '2017-01', |
178 |
'monograph_volume' => '', |
179 |
'monograph_edition' => '', |
180 |
'access_type' => 'P', |
181 |
'first_author' => '', |
182 |
'num_first_issue_online' => '1', |
183 |
'first_editor' => '', |
184 |
'publication_title' => 'Nature Astronomy', |
185 |
'date_monograph_published_print' => '', |
186 |
'publication_type' => 'serial', |
187 |
'title_id' => '4bbb0', |
188 |
'coverage_depth' => 'fulltext', |
189 |
'coverage_notes' => 'Hybrid (Open Choice)', |
190 |
'date_last_issue_online' => '' |
191 |
}; |
192 |
|
193 |
is_deeply( $title_from_line1, $line1_match, 'Title hash created correctly' ); |
194 |
is_deeply( $title_from_line2, $line2_match, 'Title hash created correctly' ); |
195 |
}; |
196 |
|
197 |
subtest 'create_title_hash_from_line_data with invalid columns using csv' => sub { |
198 |
|
199 |
plan tests => 2; |
200 |
|
201 |
my $file = { |
202 |
filename => 'Test_file.csv', |
203 |
file_content => encode_base64( |
204 |
'publication_title,print_identifier,online_identifier,date_first_issue_online,num_first_vol_online,num_first_issue_online,date_last_issue_online,num_last_vol_online,num_last_issue_online,title_url,first_author,title_id,embargo_info,coverage_depth,coverage_notes,publisher_name,publication_type,date_monograph_published_print,date_monograph_published_online,monograph_volume,monograph_edition,first_editor,parent_publication_title_id,preceding_publication_title_id,access_type,invalid_column |
205 |
Nature Plants,,2055-0278,2015-01,1,1,,,,https://www.nature.com/nplants,,4aaa7,,fulltext,Hybrid (Open Choice),Nature Publishing Group UK,serial,,,,,,,,P,invalid_column_data |
206 |
Nature Astronomy,,2397-3366,2017-01,1,1,,,,https://www.nature.com/natastron,,4bbb0,,fulltext,Hybrid (Open Choice),Nature Publishing Group UK,serial,,,,,,,,P,invalid_column_data' |
207 |
) |
208 |
}; |
209 |
|
210 |
my ( $column_headers, $lines ) = Koha::BackgroundJob::ImportKBARTFile::read_file($file); |
211 |
my @invalid_columns = ('invalid_column'); |
212 |
|
213 |
my $title_from_line1 = |
214 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[0], $column_headers, \@invalid_columns ); |
215 |
my $title_from_line2 = |
216 |
Koha::BackgroundJob::ImportKBARTFile::create_title_hash_from_line_data( @{$lines}[1], $column_headers, \@invalid_columns ); |
136 |
|
217 |
|
137 |
my $line1_match = { |
218 |
my $line1_match = { |
138 |
'coverage_depth' => 'fulltext', |
219 |
'coverage_depth' => 'fulltext', |
139 |
- |
|
|