elibri_onix_mocks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,801 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'mocha'
4
+ module Elibri
5
+ class XmlMocks
6
+
7
+ COVER_TYPES= [ 1 => 'gąbka',
8
+ 2 => 'kartonowa',
9
+ 3 => 'kartonowa foliowana',
10
+ 4 => 'miękka',
11
+ 5 => 'miękka ze skrzydełkami',
12
+ 6 => 'plastikowa',
13
+ 7 => 'skórzana',
14
+ 8 => 'twarda',
15
+ 9 => 'twarda z obwolutą',
16
+ 10 => 'twarda lakierowana']
17
+
18
+ HARDBACK = 8
19
+ PLASTIC = 6
20
+ PAPERBACK = 4
21
+
22
+ # Przykładowe produkty dla generatora XML. Są to sztuczne twory (nie ma sensu tworzyć rekordów
23
+ # w bazie). Mają tylko służyć jako model, z którego można utworzyć jak najwięcej tagów z subsetu
24
+ # ONIX wykorzystywanego w Elibri.
25
+ # TODO: Czy to jest dobre miejsce na coś takiego?
26
+ module Examples
27
+ extend self
28
+
29
+ # Dla uproszczenia stub`ujemy większość funkcjonalności:
30
+ extend Mocha::API
31
+
32
+
33
+ # Najprostszy produkt, dla którego XML się waliduje przez RelaxNG
34
+ def basic_product(options = {})
35
+ opt = {:title => "Nielegalni",
36
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
37
+ :ean => nil,
38
+ :isbn_value => '9788324799992',
39
+ :record_reference => "fdb8fa072be774d97a97",
40
+ :facsimiles => [],
41
+ :similar_products => [],
42
+ :state => "published",
43
+ :public? => true}.merge(options)
44
+ mock("product") do |product|
45
+ product.stubs(
46
+ opt
47
+ )
48
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
49
+ end
50
+
51
+
52
+ def book_example(options = {})
53
+ opt = {
54
+ :state => "published",
55
+ :public? => true,
56
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
57
+ :cover_type_id => Elibri::XmlMocks::PAPERBACK,
58
+ :publishing_status_onix_code => Elibri::ONIX::Dict::Release_3_0::PublishingStatusCode::ACTIVE,
59
+ :publication_year => 2011,
60
+ :publication_month => 2,
61
+ :publication_day => 10,
62
+ :publisher_symbol => "W pustyni i w puszczy",
63
+ :record_reference => "fdb8fa072be774d97a97",
64
+ :imprint => stub('Imprint', :name => 'National Geographic'),
65
+ :publisher_name => 'GREG',
66
+ :publisher_id => 11,
67
+ :ean => '9788324788882',
68
+ :isbn_value => '9788324799992',
69
+ :pack_quantity => 7,
70
+ :price_printed_on_product_onix_code => Elibri::ONIX::Dict::Release_3_0::PricePrintedOnProduct::YES,
71
+ :width => 125,
72
+ :height => 195,
73
+ :thickness => 20,
74
+ :weight => 90,
75
+ :number_of_pages => 250,
76
+ :number_of_illustrations => 32,
77
+ :kind_of_book? => true,
78
+ :kind_of_ebook? => true,
79
+ :kind_of_audio? => true,
80
+ :kind_of_map? => true,
81
+ #:map_scale => '20000',
82
+ :elibri_product_category1_id => 1110,
83
+ :elibri_product_category2_id => 491,
84
+ :deletion_text => 'Rekord miał sporo błędów',
85
+ :sale_restricted? => true,
86
+ :sale_restricted_for => 'sklep.gildia.pl',
87
+ :sale_restricted_to => Date.new(2012, 7, 22),
88
+ :audience_age_from => 7,
89
+ :audience_age_to => 25,
90
+ # Trochę oszukujemy, żeby w XML`u pokazać wszystkie 3 opcje:
91
+ :authorship_kind => stub('AuthorshipKind', :user_given? => true, :collective? => false, :no_contributor? => false),
92
+ :contributors => [
93
+ stub('Contributor',
94
+ :artificial_id => 257,
95
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
96
+ :language_onix_code => 'pol',
97
+ :title => 'prof.',
98
+ :name => 'Henryk',
99
+ :last_name_prefix => 'von',
100
+ :last_name => 'Sienkiewicz',
101
+ :last_name_postfix => 'Ibrahim',
102
+ :biography => stub('OtherText', :text => 'Biografia Sienkiewicza', :exportable? => true, :is_a_review? => false, :resource_link => 'http://example').extend(MockMethodMissing),
103
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
104
+ ).extend(MockMethodMissing)
105
+ ],
106
+ :or_title => "Tytuł oryginalny",
107
+ :trade_title => "Tytuł handlowy",
108
+ :vat => 5,
109
+ :pkwiu => "58.11.1",
110
+ :price_amount => 12.99,
111
+ :collection_part => 'Tom 1',
112
+ :title => 'Tytuł',
113
+ :subtitle => 'Podtytuł',
114
+ :collection => stub('PublisherCollection', :name => 'Nazwa kolekcji'),
115
+ :edition_statement => 'wyd. 3, poprawione',
116
+ :languages => [stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT)],
117
+ :other_texts => [
118
+ stub('OtherText',
119
+ :artificial_id => 137,
120
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
121
+ :text => 'Recenzja książki',
122
+ :text_author => 'Jan Kowalski',
123
+ :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
124
+ :exportable? => true,
125
+ :is_a_review? => true,
126
+ :resource_link => 'http://example'
127
+ ).extend(MockMethodMissing)
128
+ ],
129
+ :series_membership_kind => stub('series_membership_kind', :user_given? => true),
130
+ :series_memberships => [
131
+ stub('SeriesMembership', :series_name => 'Lektury szkolne', :number_within_series => '2').extend(MockMethodMissing)
132
+ ],
133
+ :facsimiles => [stub('Product', :publisher_name => 'PWN', :publisher_id => 12, :publisher_symbol => 'Tytuł dodruku', :isbn_value => '9788324705818')],
134
+ :similar_products => [stub('Product', :publisher_name => 'WNT', :publisher_id => 13, :publisher_symbol => 'Tytuł podobnej książki', :isbn_value => '9788324799992')],
135
+ :attachments => [
136
+ stub('ProductAttachment',
137
+ :id => 668,
138
+ :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
139
+ :file_content_type => 'image/png',
140
+ :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::IMAGE,
141
+ :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.png'),
142
+ :updated_at => Date.new(2011, 12, 01).to_time + 19.hours + 5.minutes + 28.seconds
143
+ ).extend(MockMethodMissing)
144
+ ],
145
+ :product_availabilities => [
146
+ stub('ProductAvailability',
147
+ :supplier_identifier => 'GILD-123',
148
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
149
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
150
+ :supplier => stub('Supplier',
151
+ :name => 'Gildia.pl',
152
+ :nip => '521-33-59-408',
153
+ :phone => '22 631 40 83',
154
+ :email => 'bok@gildia.pl',
155
+ :website => 'http://gildia.pl'
156
+ ),
157
+ :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
158
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
159
+ ).extend(MockMethodMissing),
160
+
161
+ stub('ProductAvailability',
162
+ :supplier_identifier => 'pl.pwn.ksiegarnia.produkt.id.76734',
163
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER,
164
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
165
+ :supplier => stub('Supplier',
166
+ :name => 'PWN',
167
+ :nip => '521-33-59-408',
168
+ :phone => '22 631 40 83',
169
+ :email => 'bok@pwn.pl',
170
+ :website => 'http://pwn.pl'
171
+ ).extend(MockMethodMissing),
172
+ :stock_info => stub('stock_info', :exact_info? => false, :quantity_code => 'mało'),
173
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 10, :amount => 14.99, :vat => 7, :currency_code => 'PLN') ]
174
+ ).extend(MockMethodMissing)
175
+ ]
176
+ }.merge(options)
177
+ mock("product").tap do |product|
178
+ product.stubs(
179
+ opt
180
+ )
181
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
182
+ end
183
+
184
+ def onix_record_identifiers_example(options = {})
185
+ opt = {
186
+ :state => "published",
187
+ :title => "Nielegalni",
188
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
189
+ :record_reference => "fdb8fa072be774d97a97",
190
+ :ean => '9788324788882',
191
+ :isbn_value => '9788324799992',
192
+ :public? => true,
193
+ :product_availabilities => [
194
+ stub('ProductAvailability', :supplier_identifier => '355006',
195
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
196
+ :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
197
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ],
198
+ :supplier => stub('Supplier', :name => "Olesiejuk",
199
+ :nip => "527-22-62-432", :phone => "22 721 70 07", :email => "", :website => "www.olesiejuk.pl"),
200
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER).extend(MockMethodMissing)
201
+ ]
202
+ }.merge(options)
203
+ mock("product").tap do |product|
204
+ product.stubs(
205
+ opt
206
+ )
207
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
208
+ end
209
+
210
+
211
+ def onix_product_form_example(options = {})
212
+ opt = {
213
+ :title => "Nielegalni",
214
+ :ean => nil,
215
+ :isbn_value => '9788324799992',
216
+ :record_reference => "fdb8fa072be774d97a97",
217
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
218
+ :cover_type_id => Elibri::XmlMocks::PAPERBACK,
219
+ :state => "published",
220
+ :public? => true,
221
+ :product_availabilities => []
222
+ }.merge(options)
223
+ mock("product").tap do |product|
224
+ product.stubs(
225
+ opt
226
+ )
227
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
228
+ end
229
+
230
+
231
+ def onix_epub_details_example(options = {})
232
+ opt = {
233
+ :title => "Nielegalni",
234
+ :ean => nil,
235
+ :isbn_value => '9788324799992',
236
+ :record_reference => "fdb8fa072be774d97a97",
237
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::EBOOK,
238
+ :epub_technical_protection_onix_code => Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::DRM,
239
+ :product_form_detail_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::EPUB,
240
+ :state => "published",
241
+ :public? => true,
242
+ :product_availabilities => []
243
+ }.merge(options)
244
+ mock("product").tap do |product|
245
+ product.stubs(
246
+ opt
247
+ )
248
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
249
+ end
250
+
251
+
252
+ def onix_categories_example(options = {})
253
+ opt = {
254
+ :publisher_name => "Buchmann",
255
+ :publisher_id => 15,
256
+ :publisher_product_categories => [
257
+ stub('PublisherProductCategory', :name => "Beletrystyka: Horror"),
258
+ stub('PublisherProductCategory', :name => "Beletrystyka: Sensacja")
259
+ ]
260
+ }.merge(options)
261
+ basic_product.tap do |product|
262
+ product.stubs(
263
+ opt
264
+ )
265
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
266
+ end
267
+
268
+ def onix_languages_example(options = {})
269
+ opt = {
270
+ :languages => [
271
+ stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT),
272
+ stub('Language', :language_onix_code => 'eng', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_ABSTRACTS)
273
+ ]
274
+ }.merge(options)
275
+ basic_product.tap do |product|
276
+ product.stubs(
277
+ opt
278
+ )
279
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
280
+ end
281
+
282
+
283
+ def onix_measurement_example(options = {})
284
+ opt = {
285
+ :title => "Katowice, mapa",
286
+ :ean => nil,
287
+ :isbn_value => '9788324799992',
288
+ :record_reference => "fdb8fa072be774d97a97",
289
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::SHEET_MAP,
290
+ :width => 125,
291
+ :height => 195,
292
+ :thickness => 20,
293
+ :weight => 90,
294
+ :map_scale => 50_000,
295
+ :state => "published",
296
+ :public? => true
297
+ }.merge(options)
298
+ mock("product").tap do |product|
299
+ product.stubs(
300
+ opt
301
+ )
302
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
303
+ end
304
+
305
+
306
+ def onix_sale_restrictions_example(options = {})
307
+ opt = {
308
+ :sale_restricted? => true,
309
+ :sale_restricted_for => 'Empik',
310
+ :sale_restricted_to => Date.new(2012, 7, 22),
311
+ :publication_year => 2012,
312
+ :publication_month => 7,
313
+ :publication_day => 12
314
+ }.merge(options)
315
+ basic_product.tap do |product|
316
+ product.stubs(
317
+ opt
318
+ )
319
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
320
+ end
321
+
322
+
323
+ def onix_audience_range_example(options = {})
324
+ opt = {
325
+ :audience_age_from => 7,
326
+ :audience_age_to => 10
327
+ }.merge(options)
328
+ basic_product.tap do |product|
329
+ product.stubs(
330
+ opt
331
+ )
332
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
333
+ end
334
+
335
+
336
+ def onix_publisher_info_example(options = {})
337
+ opt = {
338
+ :publisher_name => 'G+J Gruner+Jahr Polska',
339
+ :publisher_id => 14,
340
+ :imprint => stub('Imprint', :name => 'National Geographic')
341
+ }.merge(options)
342
+ basic_product.tap do |product|
343
+ product.stubs(
344
+ opt
345
+ )
346
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
347
+ end
348
+
349
+
350
+
351
+ def onix_subjects_example(options = {})
352
+ opt = {
353
+ :elibri_product_category1_id => 1110,
354
+ :elibri_product_category2_id => 491
355
+ }.merge(options)
356
+ basic_product.tap do |product|
357
+ product.stubs(
358
+ opt
359
+ )
360
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
361
+ end
362
+
363
+
364
+ def onix_edition_example(options = {})
365
+ opt = {
366
+ :edition_statement => 'wyd. 3, poprawione'
367
+ }.merge(options)
368
+ basic_product.tap do |product|
369
+ product.stubs(
370
+ opt
371
+ )
372
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
373
+ end
374
+
375
+
376
+ def onix_ebook_extent_example(options = {})
377
+ opt = {
378
+ :example_title => 'E-book (rozmiar pliku, ilość stron i obrazków)',
379
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::EBOOK,
380
+ :file_size => 1.22,
381
+ :number_of_pages => 150,
382
+ :number_of_illustrations => 12
383
+ }.merge(options)
384
+ basic_product.tap do |product|
385
+ product.stubs(
386
+ opt
387
+ )
388
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
389
+ end
390
+
391
+ def onix_audiobook_extent_example(options = {})
392
+ opt = {
393
+ :example_title => 'Audio CD z długością ścieżki',
394
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::AUDIO_CD,
395
+ :duration => 340
396
+ }.merge(options)
397
+ basic_product.tap do |product|
398
+ product.stubs(
399
+ opt
400
+ )
401
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
402
+ end
403
+
404
+ def onix_no_contributors_example(options = {})
405
+ opt = {
406
+ :example_title => 'Brak autorów',
407
+ :authorship_kind => ActiveSupport::StringInquirer.new("no_contributor")
408
+ }.merge(options)
409
+ basic_product.tap do |product|
410
+ product.stubs(
411
+ opt
412
+ )
413
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
414
+ end
415
+
416
+ def onix_collective_work_example(options = {})
417
+ opt = {
418
+ :example_title => 'Praca zbiorowa',
419
+ :authorship_kind => ActiveSupport::StringInquirer.new("collective")
420
+ }.merge(options)
421
+ basic_product.tap do |product|
422
+ product.stubs(
423
+ opt
424
+ )
425
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
426
+ end
427
+
428
+ def onix_contributors_example(options = {})
429
+ opt = {
430
+ :example_title => 'Wyszczególnieni autorzy',
431
+ :title => "Taka jest nasza wiara",
432
+ :authorship_kind => ActiveSupport::StringInquirer.new("user_given"),
433
+ :contributors => [
434
+ stub('Contributor',
435
+ :artificial_id => 255,
436
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
437
+ :missing_parts => true,
438
+ :full_name => 'Św. Tomasz z Akwinu',
439
+ :biography => stub('OtherText', :text => 'Tomasz z Akwinu, Akwinata, łac. Thoma de Aquino (ur. 1225, zm. 7 marca 1274) – filozof scholastyczny, teolog, członek zakonu dominikanów. Był jednym z najwybitniejszych myślicieli w dziejach chrześcijaństwa. Święty Kościoła katolickiego, jeden z doktorów Kościoła, który nauczając przekazywał owoce swej kontemplacji (łac. contemplata aliis tradere).'),
440
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
441
+ ).extend(MockMethodMissing),
442
+ stub('Contributor',
443
+ :artificial_id => 256,
444
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
445
+ :language_onix_code => 'lat',
446
+ :title => 'prof. ks.',
447
+ :name => 'Henryk',
448
+ :last_name_prefix => 'von',
449
+ :last_name => 'Hausswolff',
450
+ :last_name_postfix => 'OP',
451
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
452
+ ).extend(MockMethodMissing)
453
+ ]
454
+ }.merge(options)
455
+ basic_product.tap do |product|
456
+ product.stubs(
457
+ opt
458
+ )
459
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
460
+ end
461
+
462
+ def onix_announced_product_example(options = {})
463
+ opt = {
464
+ :state => :announced,
465
+ :publisher_symbol => "Światu nie mamy czego zazdrościć.",
466
+ :or_title => "Nothing to Envy: Ordinary Lives in North Korea",
467
+ :collection_part => '33',
468
+ :title => 'Światu nie mamy czego zazdrościć.',
469
+ :subtitle => "Zwyczajne losy mieszkańców Korei Północnej.",
470
+ :publication_year => 2011
471
+ }.merge(options)
472
+ basic_product.tap do |product|
473
+ product.stubs(
474
+ opt
475
+ )
476
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
477
+ end
478
+
479
+ def onix_preorder_product_example(options = {})
480
+ opt = {
481
+ :state => :preorder,
482
+ :publication_year => 2011,
483
+ :publication_month => 2,
484
+ :publication_day => 10
485
+ }.merge(options)
486
+ basic_product.tap do |product|
487
+ product.stubs(
488
+ opt
489
+ )
490
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
491
+ end
492
+
493
+ def onix_published_product_example(options = {})
494
+ opt = {
495
+ :state => :published,
496
+ :publication_year => 2011,
497
+ :publication_month => 2
498
+ }.merge(options)
499
+ basic_product.tap do |product|
500
+ product.stubs(
501
+ opt
502
+ )
503
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
504
+ end
505
+
506
+ def onix_out_of_print_product_example(options = {})
507
+ opt = {
508
+ :state => :out_of_print
509
+ }.merge(options)
510
+ basic_product.tap do |product|
511
+ product.stubs(
512
+ opt
513
+ )
514
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
515
+ end
516
+
517
+ def onix_titles_example(options = {})
518
+ opt = {
519
+ :publisher_symbol => "Światu nie mamy czego zazdrościć.",
520
+ :or_title => "Nothing to Envy: Ordinary Lives in North Korea",
521
+ :collection_part => '33',
522
+ :title => 'Światu nie mamy czego zazdrościć.',
523
+ :subtitle => "Zwyczajne losy mieszkańców Korei Północnej."
524
+ }.merge(options)
525
+ basic_product.tap do |product|
526
+ product.stubs(
527
+ opt
528
+ )
529
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
530
+ end
531
+
532
+ def onix_title_with_collection_example(options = {})
533
+ opt = {
534
+ :publisher_symbol => "Thorgal 33 Statek-Miecz TWARDA",
535
+ :or_title => "Thorgal: Le Bateau-Sabre",
536
+ :collection_part => '33',
537
+ :title => 'Statek-Miecz',
538
+ :collection => stub('PublisherCollection', :name => 'Thorgal')
539
+ }.merge(options)
540
+ basic_product.tap do |product|
541
+ product.stubs(
542
+ opt
543
+ )
544
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
545
+ end
546
+
547
+
548
+
549
+ def onix_texts_example(options = {})
550
+ opt = {
551
+ :other_texts => [
552
+ stub('OtherText',
553
+ :artificial_id => 133,
554
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::TABLE_OF_CONTENTS,
555
+ :text => '1. Wprowadzenie<br/>2. Rozdział pierwszy<br/>[...]',
556
+ :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 15.minutes + 5.seconds
557
+ ).extend(MockMethodMissing),
558
+ stub('OtherText',
559
+ :artificial_id => 134,
560
+ :exportable_review => true,
561
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
562
+ :text => 'Recenzja książki<br/>[...]',
563
+ :resource_link => 'http://nakanapie.pl/books/420469/reviews/2892.odnalezc-swa-droge',
564
+ :source_title => 'nakanapie.pl',
565
+ :text_author => 'Jan Kowalski',
566
+ :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 18.minutes + 15.seconds
567
+ ).extend(MockMethodMissing),
568
+ stub('OtherText',
569
+ :artificial_id => 135,
570
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::MAIN_DESCRIPTION,
571
+ :text => 'Opis książki<br/>[...]',
572
+ :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 25.minutes + 18.seconds
573
+ ).extend(MockMethodMissing),
574
+ stub('OtherText',
575
+ :artificial_id => 136,
576
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::EXCERPT,
577
+ :text => 'Fragment książki<br/>[...]',
578
+ :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 35.minutes + 2.seconds
579
+ ).extend(MockMethodMissing),
580
+ ]
581
+ }.merge(options)
582
+ basic_product.tap do |product|
583
+ product.stubs(
584
+ opt
585
+ )
586
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
587
+ end
588
+
589
+
590
+ def onix_related_products_example(options = {})
591
+ opt = {
592
+ :facsimiles => [stub('Product', :publisher_name => 'PWN', :publisher_id => 11, :publisher_symbol => 'Tytuł dodruku', :isbn_value => '9788324705818')],
593
+ :similar_products => [stub('Product', :publisher_name => 'WNT', :publisher_id => 12, :publisher_symbol => 'Tytuł podobnej książki', :isbn_value => '9788324799992')]
594
+ }.merge(options)
595
+ basic_product.tap do |product|
596
+ product.stubs(
597
+ opt
598
+ )
599
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
600
+ end
601
+
602
+
603
+ def onix_supply_details_example(options = {})
604
+ opt = {
605
+ :product_availabilities => [
606
+ stub('ProductAvailability',
607
+ :supplier_identifier => 'GILD-123',
608
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
609
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
610
+ :supplier => stub('Supplier',
611
+ :name => 'Gildia.pl',
612
+ :nip => '521-33-59-408',
613
+ :phone => '22 631 40 83',
614
+ :email => 'bok@gildia.pl',
615
+ :website => 'http://gildia.pl'
616
+ ),
617
+ :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
618
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
619
+ ),
620
+
621
+ stub('ProductAvailability',
622
+ :supplier_identifier => 'pl.pwn.ksiegarnia.produkt.id.76734',
623
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER,
624
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
625
+ :supplier => stub('Supplier',
626
+ :name => 'PWN',
627
+ :nip => '521-33-59-408',
628
+ :phone => '22 631 40 83',
629
+ :email => 'bok@pwn.pl',
630
+ :website => 'http://www.pwn.pl'
631
+ ),
632
+ :stock_info => stub('stock_info', :exact_info? => false, :quantity_code => 'mało'),
633
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 10, :amount => 14.99, :vat => 7, :currency_code => 'PLN') ]
634
+ )
635
+ ]
636
+ }.merge(options)
637
+ basic_product.tap do |product|
638
+ product.stubs(
639
+ opt
640
+ )
641
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
642
+ end
643
+
644
+
645
+ def onix_series_memberships_example(options = {})
646
+ opt = {
647
+ :series_membership_kind => stub('series_membership_kind', :user_given? => true),
648
+ :series_memberships => [
649
+ stub('SeriesMembership', :series_name => 'Lektury szkolne', :number_within_series => '2'),
650
+ stub('SeriesMembership', :series_name => 'Dla Bystrzaków', :number_within_series => '1')
651
+ ]
652
+ }.merge(options)
653
+ basic_product.tap do |product|
654
+ product.stubs(
655
+ opt
656
+ )
657
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
658
+ end
659
+
660
+
661
+ def onix_supporting_resources_example(options = {})
662
+ opt = {
663
+ :attachments => [
664
+ stub('ProductAttachment',
665
+ :id => 667,
666
+ :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
667
+ :file_content_type => 'image/png',
668
+ :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::IMAGE,
669
+ :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.png'),
670
+ :updated_at => Date.new(2011, 12, 01).to_time + 18.hours + 5.minutes + 28.seconds
671
+ ),
672
+ stub('ProductAttachment',
673
+ :id => 668,
674
+ :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::SAMPLE_CONTENT,
675
+ :file_content_type => 'application/pdf',
676
+ :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::TEXT,
677
+ :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.pdf'),
678
+ :updated_at => Date.new(2011, 12, 01).to_time + 18.hours + 9.minutes + 18.seconds
679
+ )
680
+ ]
681
+ }.merge(options)
682
+ basic_product.tap do |product|
683
+ product.stubs(
684
+ opt
685
+ )
686
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
687
+ end
688
+
689
+
690
+ def onix_elibri_extensions_example(options = {})
691
+ opt = {
692
+ :cover_type_id => Elibri::XmlMocks::PAPERBACK,
693
+ :vat => 5,
694
+ :pkwiu => "58.11.1",
695
+ :price_amount => 12.99,
696
+ :preview_exists? => true
697
+ }.merge(options)
698
+ basic_product.tap do |product|
699
+ product.stubs(
700
+ opt
701
+ )
702
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
703
+ end
704
+
705
+
706
+ def contributor_mock(options = {})
707
+ opt = {
708
+ :artificial_id => 240,
709
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
710
+ :language_onix_code => 'pol',
711
+ :title => 'prof.',
712
+ :name => 'Henryk',
713
+ :last_name_prefix => 'von',
714
+ :last_name => 'Sienkiewicz',
715
+ :last_name_postfix => 'Ibrahim',
716
+ :biography => stub('OtherText', :text => 'Biografia Sienkiewicza', :exportable? => true, :is_a_review? => false, :resource_link => 'http://example').extend(MockMethodMissing),
717
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
718
+ }.merge(options)
719
+ mock('Contributor').tap do |contributor|
720
+ contributor.stubs(
721
+ opt
722
+ )
723
+ end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
724
+ end
725
+
726
+ def review_mock(options = {})
727
+ opt = {
728
+ :artificial_id => 137,
729
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
730
+ :text => 'Recenzja książki',
731
+ :text_author => 'Jan Kowalski',
732
+ :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
733
+ :exportable? => true,
734
+ :is_a_review? => true,
735
+ :resource_link => 'http://example'
736
+ }.merge(options)
737
+ mock('OtherText').tap do |other_text|
738
+ other_text.stubs(
739
+ opt
740
+ )
741
+ end.extend(MockMethodMissing)
742
+ end
743
+
744
+ def supply_detail_mock(options = {})
745
+ opt =
746
+ {
747
+ :supplier_identifier => 'GILD-123',
748
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
749
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
750
+ :supplier => stub('Supplier',
751
+ :name => 'Gildia.pl',
752
+ :nip => '521-33-59-408',
753
+ :phone => '22 631 40 83',
754
+ :email => 'bok@gildia.pl',
755
+ :website => 'http://gildia.pl'
756
+ ),
757
+ :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
758
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
759
+ }.merge(options)
760
+ mock('ProductAvailability').tap do |aval|
761
+ aval.stubs(
762
+ opt
763
+ )
764
+ end.extend(MockMethodMissing)
765
+ end
766
+
767
+ def imprint_mock(options = {})
768
+ opt =
769
+ {
770
+ :name => 'National Geographic'
771
+ }.merge(options)
772
+ mock('Imprint').tap do |impr|
773
+ impr.stubs(
774
+ opt
775
+ )
776
+ end.extend(MockMethodMissing)
777
+ end
778
+
779
+ def description_mock(options = {})
780
+ opt =
781
+ {
782
+ :artificial_id => 137,
783
+ :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::MAIN_DESCRIPTION,
784
+ :text => 'Recenzja książki',
785
+ :text_author => 'Jan Kowalski',
786
+ :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
787
+ :exportable? => true,
788
+ :is_a_review? => false,
789
+ :resource_link => 'http://example'
790
+ }.merge(options)
791
+ mock('OtherText').tap do |descr|
792
+ descr.stubs(
793
+ opt
794
+ )
795
+ end.extend(MockMethodMissing)
796
+ end
797
+
798
+
799
+ end
800
+ end
801
+ end