itunes_store_transporter 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ shared_examples_for "a boolean transporter option" do |option, expected|
41
41
 
42
42
  context "when not boolean" do
43
43
  it "raises an OptionError" do
44
- lambda { subject.run(options.merge(option => "sshaw")) }.should raise_exception(ITunes::Store::Transporter::OptionError, /does not accept/)
44
+ expect { subject.run(options.merge(option => "sshaw")) }.to raise_exception(ITunes::Store::Transporter::OptionError, /does not accept/)
45
45
  end
46
46
  end
47
47
  end
@@ -49,7 +49,7 @@ end
49
49
  shared_examples_for "a required option" do |option|
50
50
  it "must have a value" do
51
51
  ["", nil].each do |value|
52
- lambda { subject.run(options.merge(option => value)) }.should raise_exception(ITunes::Store::Transporter::OptionError, /#{option}/)
52
+ expect { subject.run(options.merge(option => value)) }.to raise_exception(ITunes::Store::Transporter::OptionError, /#{option}/)
53
53
  end
54
54
  end
55
55
  end
@@ -57,20 +57,20 @@ end
57
57
  shared_examples_for "a command that accepts a shortname argument" do
58
58
  context "when the shortname's invalid" do
59
59
  it "raises an OptionError" do
60
- lambda { subject.run(options.merge(:shortname => "+")) }.should raise_exception(ITunes::Store::Transporter::OptionError, /shortname/)
60
+ expect { subject.run(options.merge(:shortname => "+")) }.to raise_exception(ITunes::Store::Transporter::OptionError, /shortname/)
61
61
  end
62
62
  end
63
63
 
64
64
  context "when the shortname's valid" do
65
65
  it "does not raise an exception" do
66
66
  mock_output
67
- lambda { subject.run(options.merge(:shortname => "Too $hort")) }.should_not raise_exception
67
+ expect { subject.run(options.merge(:shortname => "Too $hort")) }.to_not raise_exception
68
68
  end
69
69
  end
70
70
  end
71
71
 
72
72
  shared_examples_for "a subclass of Command::Base" do
73
- it { should be_a_kind_of(ITunes::Store::Transporter::Command::Base) }
73
+ it { is_expected.to be_a_kind_of(ITunes::Store::Transporter::Command::Base) }
74
74
 
75
75
  context "when on Windows" do
76
76
  it "automatically sets NoPause to true" do
@@ -105,7 +105,7 @@ shared_examples_for "a subclass of Command::Base" do
105
105
  let(:print?) { false }
106
106
 
107
107
  it "does not print to stderr" do
108
- $stderr.string.should be_empty
108
+ expect($stderr.string).to be_empty
109
109
  end
110
110
  end
111
111
  end
@@ -133,7 +133,7 @@ shared_examples_for "a subclass of Command::Base" do
133
133
  let(:print?) { false }
134
134
 
135
135
  it "does not print to stdout" do
136
- $stdout.string.should be_empty
136
+ expect($stdout.string).to be_empty
137
137
  end
138
138
  end
139
139
  end
@@ -160,17 +160,17 @@ shared_examples_for "a subclass of Command::Base" do
160
160
  it "raises an ExecutionError" do
161
161
  mock_output(:exit => 1, :stderr => "stderr.errors")
162
162
  lambda { subject.run(options) }.should raise_error { |e|
163
- e.should be_a(ITunes::Store::Transporter::ExecutionError)
163
+ expect(e).to be_a(ITunes::Store::Transporter::ExecutionError)
164
164
 
165
- e.exitstatus.should == 1
166
- e.errors.should have(2).items
165
+ expect(e.exitstatus).to eq 1
166
+ expect(e.errors.size).to eq 2
167
167
 
168
168
  # just check one
169
- e.errors[0].should be_a(ITunes::Store::Transporter::TransporterMessage)
170
- e.errors[0].code.should == 9000
171
- e.errors[0].message.should match("Your audio of screwed up!")
172
- e.errors[1].code.should == 4009
173
- e.errors[1].message.should match("Chapter timecode is just plain wrong")
169
+ expect(e.errors[0]).to be_a(ITunes::Store::Transporter::TransporterMessage)
170
+ expect(e.errors[0].code).to eq 9000
171
+ expect(e.errors[0].message).to match("Your audio of screwed up!")
172
+ expect(e.errors[1].code).to eq 4009
173
+ expect(e.errors[1].message).to match("Chapter timecode is just plain wrong")
174
174
  }
175
175
  end
176
176
  end
@@ -179,18 +179,18 @@ end
179
179
 
180
180
  shared_examples_for "a transporter mode" do
181
181
  it_should_behave_like "a subclass of Command::Base"
182
- it { should be_a_kind_of(ITunes::Store::Transporter::Command::Mode) }
182
+ it { is_expected.to be_a_kind_of(ITunes::Store::Transporter::Command::Mode) }
183
183
 
184
184
  it "requires a username" do
185
185
  args = options
186
186
  args.delete(:username)
187
- lambda { subject.run(args) }.should raise_error(ITunes::Store::Transporter::OptionError, /username/)
187
+ expect { subject.run(args) }.to raise_error(ITunes::Store::Transporter::OptionError, /username/)
188
188
  end
189
189
 
190
190
  it "requires a password" do
191
191
  args = options
192
192
  args.delete(:password)
193
- lambda { subject.run(args) }.should raise_error(ITunes::Store::Transporter::OptionError, /password/)
193
+ expect { subject.run(args) }.to raise_error(ITunes::Store::Transporter::OptionError, /password/)
194
194
  end
195
195
  end
196
196
 
@@ -269,13 +269,17 @@ describe ITunes::Store::Transporter::Command::Providers do
269
269
 
270
270
  subject { described_class.new({}) }
271
271
  let(:options) { create_options }
272
- its(:mode) { should == "provider" }
272
+
273
+ it "uses Transporter's provider mode" do
274
+ expect_shell_args("-m", "provider")
275
+ subject.run(options)
276
+ end
273
277
 
274
278
  describe "#run" do
275
279
  it "returns the shortname and longname for each provider" do
276
280
  mock_output(:stdout => "providers.two", :stderr => "stderr.info")
277
- subject.run(options).should == [ { :longname => "Some Great User", :shortname => "luser" },
278
- { :longname => "Skye's Taco Eating Service Inc.", :shortname => "conmuchacebolla" } ]
281
+ expect(subject.run(options)).to eq [ { :longname => "Some Great User", :shortname => "luser" },
282
+ { :longname => "Skye's Taco Eating Service Inc.", :shortname => "conmuchacebolla" } ]
279
283
  end
280
284
  end
281
285
  end
@@ -293,7 +297,7 @@ describe ITunes::Store::Transporter::Command::Upload do
293
297
  context "when successful" do
294
298
  it "returns true" do
295
299
  mock_output(:stdout => "stdout.success")
296
- subject.run(options).should be_true
300
+ expect(subject.run(options)).to be true
297
301
  end
298
302
  end
299
303
  end
@@ -301,7 +305,7 @@ describe ITunes::Store::Transporter::Command::Upload do
301
305
  describe "options" do
302
306
  describe ":rate" do
303
307
  it "must be an integer" do
304
- lambda { subject.run(options.merge(:rate => "123")) }.should raise_exception(ITunes::Store::Transporter::OptionError, /rate/)
308
+ expect { subject.run(options.merge(:rate => "123")) }.to raise_exception(ITunes::Store::Transporter::OptionError, /rate/)
305
309
  end
306
310
 
307
311
  it_should_behave_like "a transporter option", {:rate => 123}, "-k", "123"
@@ -315,11 +319,11 @@ describe ITunes::Store::Transporter::Command::Upload do
315
319
  end
316
320
 
317
321
  it "is case sensitive" do
318
- lambda { subject.run(options.merge(:transport => "aspera")) }.should raise_exception(ITunes::Store::Transporter::OptionError)
322
+ expect { subject.run(options.merge(:transport => "aspera")) }.to raise_exception(ITunes::Store::Transporter::OptionError)
319
323
  end
320
324
 
321
325
  it "raises an OptionError if the transport is not supported" do
322
- lambda { subject.run(options.merge(:transport => "ftp")) }.should raise_exception(ITunes::Store::Transporter::OptionError)
326
+ expect { subject.run(options.merge(:transport => "ftp")) }.to raise_exception(ITunes::Store::Transporter::OptionError)
323
327
  end
324
328
  end
325
329
 
@@ -348,7 +352,6 @@ describe ITunes::Store::Transporter::Command::Lookup do
348
352
  subject { described_class.new({}) }
349
353
 
350
354
  let(:options) { create_options(:vendor_id => "X") }
351
- its(:mode) { should == "lookupMetadata" }
352
355
 
353
356
  # Fake the directory iTMSTransporter creates for the metadata
354
357
  before(:each) do
@@ -365,13 +368,18 @@ describe ITunes::Store::Transporter::Command::Lookup do
365
368
 
366
369
  after(:each) { FileUtils.rm_rf(@tmpdir) }
367
370
 
371
+ it "uses Transporter's lookupMetadata mode" do
372
+ expect_shell_args("-m", "lookupMetadata")
373
+ subject.run(options)
374
+ end
375
+
368
376
  describe "#run" do
369
377
  before { mock_output }
370
378
 
371
379
  context "when successful" do
372
380
  it "returns the metadata and deletes the temp directory used to output the metadata" do
373
- subject.run(options).should == @metadata
374
- File.exists?(@tmpdir).should be_false
381
+ expect(subject.run(options)).to eq @metadata
382
+ expect(File.exists?(@tmpdir)).to be false
375
383
  end
376
384
 
377
385
  context "when the metadata file was not created" do
@@ -404,7 +412,11 @@ describe ITunes::Store::Transporter::Command::Schema do
404
412
 
405
413
  subject { described_class.new({}) }
406
414
  let(:options) { create_options(:type => "strict", :version => "film5") }
407
- its(:mode) { should == "generateSchema" }
415
+
416
+ it "uses Transporter's generateSchema mode" do
417
+ expect_shell_args("-m", "generateSchema")
418
+ subject.run(options)
419
+ end
408
420
 
409
421
  describe "#run" do
410
422
  context "when successful" do
@@ -431,47 +443,113 @@ describe ITunes::Store::Transporter::Command::Schema do
431
443
  end
432
444
  end
433
445
 
446
+ describe ITunes::Store::Transporter::Command::StatusAll do
447
+ subject { described_class.new({}) }
448
+ let(:options) { create_options(:vendor_id => 123123) }
449
+
450
+ it { is_expected.to be_kind_of(ITunes::Store::Transporter::Command::Status) }
451
+
452
+ it "uses Transporter's statusAll mode" do
453
+ expect_shell_args("-m", "statusAll", :stdout => fixture("status.vendor_id_123123"))
454
+ subject.run(options)
455
+ end
456
+ end
457
+
434
458
  describe ITunes::Store::Transporter::Command::Status do
435
- it_behaves_like "a transporter mode"
459
+ # Ugh, issue with stubbed print_stdout test, we need XML here :(
460
+ #it_behaves_like "a transporter mode"
436
461
 
437
462
  subject { described_class.new({}) }
438
463
  let(:options) { create_options(:vendor_id => 123123) }
439
- its(:mode) { should == "status" }
464
+
465
+ it "uses Transporter's status mode" do
466
+ expect_shell_args("-m", "status", :stdout => fixture("status.vendor_id_123123"))
467
+ subject.run(options)
468
+ end
469
+
470
+ it "uses Transporter's XML output format" do
471
+ expect_shell_args("-outputFormat", "xml", :stdout => fixture("status.vendor_id_123123"))
472
+ subject.run(options)
473
+ end
440
474
 
441
475
  describe "#run" do
442
476
  context "when successful" do
443
- context "with a single status" do
477
+ context "with a single id" do
444
478
  it "returns the status information for the package" do
445
479
  mock_output(:stdout => "status.vendor_id_123123", :stderr => "stderr.info")
446
- subject.run(options).should == {
447
- :vendor_identifier => "123123",
448
- :apple_identifier => "123123",
449
- :itunesconnect_status => "Not ready for sale",
450
- :status => [ { :upload_created => "2000-01-01 00:00:00",
451
- :upload_state => "Uploaded",
452
- :upload_state_id => "1",
453
- :content_state => "Irie",
454
- :content_state_id => "2" } ]
455
- }
480
+ expect(subject.run(options)).to eq [
481
+ :apple_id=>"X9123X",
482
+ :vendor_id=>"123123",
483
+ :content_status=>
484
+ {:status=>"Unpolished",
485
+ :review_status=>"Ready-NotReviewed",
486
+ :itunes_connect_status=>"Other",
487
+ :store_status=>
488
+ {:not_on_store=>[], :on_store=>[], :ready_for_store=>["US"]},
489
+ :video_components=>
490
+ [{:name=>"Video",
491
+ :locale=>nil,
492
+ :status=>"In Review",
493
+ :delivered=>"2011-11-30 01:41:10"},
494
+ {:name=>"Audio",
495
+ :locale=>"en-US",
496
+ :status=>"In Review",
497
+ :delivered=>"2011-11-30 01:41:10"}]},
498
+ :info=>[{:created=>"2016-11-25 10:38:09", :status=>"Imported"}]
499
+ ]
456
500
  end
457
501
  end
458
502
 
459
- context "with multiple status" do
460
- it "returns all the status information for the package" do
461
- mock_output(:stdout => "status.vendor_id_789789", :stderr => "stderr.info")
462
- subject.run(options).should == {
463
- :vendor_identifier => "789789",
464
- :status => [ { :upload_created => "2000-01-01 00:00:00",
465
- :upload_state => "Uploaded",
466
- :upload_state_id => "1",
467
- :content_state => "Irie",
468
- :content_state_id => "2" },
469
- { :upload_created => "2000-01-02 00:00:00",
470
- :upload_state => "Some Failure",
471
- :upload_state_id => "2",
472
- :content_state => "Still Irie",
473
- :content_state_id => "3" } ]
474
- }
503
+ context "with multiple ids" do
504
+ it "returns all the status information for all packages" do
505
+ options[:vendor_id] = %w[123123 ABCABC]
506
+ mock_output(:stdout => "status.vendor_id_123123_and_ABCABC", :stderr => "stderr.info")
507
+ expect(subject.run(options)).to eq [
508
+ {:apple_id=>"X9123X",
509
+ :vendor_id=>"123123",
510
+ :content_status=>
511
+ {:status=>"Unpolished",
512
+ :review_status=>"Ready-NotReviewed",
513
+ :itunes_connect_status=>"Other",
514
+ :store_status=>
515
+ {:not_on_store=>[], :on_store=>[], :ready_for_store=>["US"]},
516
+ :video_components=>
517
+ [{:name=>"Video",
518
+ :locale=>nil,
519
+ :status=>"In Review",
520
+ :delivered=>"2011-11-30 01:41:10"},
521
+ {:name=>"Audio",
522
+ :locale=>"en-US",
523
+ :status=>"In Review",
524
+ :delivered=>"2011-11-30 01:41:10"}]},
525
+ :info=>[{:created=>"2016-11-25 10:38:09", :status=>"Imported"}]},
526
+ {:apple_id=>"919191",
527
+ :vendor_id=>"ABCABC",
528
+ :content_status=>
529
+ {:status=>"Unpolished",
530
+ :review_status=>"Ready-NotReviewed",
531
+ :itunes_connect_status=>"Other",
532
+ :store_status=>
533
+ {:not_on_store=>[], :on_store=>["US","MX"], :ready_for_store=>["US"]},
534
+ :video_components=>
535
+ [{:name=>"Preview Film",
536
+ :locale=>"World",
537
+ :status=>"Approved",
538
+ :delivered=>"2016-11-25 12:92:46"},
539
+ {:name=>"Audio",
540
+ :locale=>"en-US",
541
+ :status=>"Approved",
542
+ :delivered=>"2016-11-25 12:11:07"},
543
+ {:name=>"Chapters",
544
+ :locale=>"en-US",
545
+ :status=>"Approved",
546
+ :delivered=>"2016-11-25 12:12:46"}]},
547
+ :info=>
548
+ [{:created=>"2011-08-25 10:50:09", :status=>"Imported"},
549
+ {:created=>"2012-11-08 08:26:11", :status=>"Imported"},
550
+ {:created=>"2013-10-31 05:55:29", :status=>"Imported"},
551
+ {:created=>"2014-11-25 10:38:09", :status=>"Imported"}]}
552
+ ]
475
553
  end
476
554
  end
477
555
  end
@@ -479,7 +557,19 @@ describe ITunes::Store::Transporter::Command::Status do
479
557
 
480
558
  describe "options" do
481
559
  describe ":vendor_id" do
482
- it_should_behave_like "a vendor_id option"
560
+ context "given a single vendor_id" do
561
+ it "passes a single id to the transporter" do
562
+ expect_shell_args("-vendor_ids", "123", :stdout => fixture("status.vendor_id_123123"))
563
+ subject.run(options.merge(:vendor_id => "123"))
564
+ end
565
+ end
566
+
567
+ context "given multiple vendor_ids" do
568
+ it "passes a single id to the transporter" do
569
+ expect_shell_args("-vendor_ids", "123,456", :stdout => fixture("status.vendor_id_123123"))
570
+ subject.run(options.merge(:vendor_id => %w[123 456]))
571
+ end
572
+ end
483
573
  end
484
574
  end
485
575
  end
@@ -490,15 +580,19 @@ describe ITunes::Store::Transporter::Command::Verify do
490
580
  it_behaves_like "a command that accepts a shortname argument"
491
581
 
492
582
  subject { described_class.new({}) }
493
- its(:mode) { should == "verify" }
494
583
  let(:options) { create_options(:package => create_package) }
495
584
 
585
+ it "uses Transporter's verify mode" do
586
+ expect_shell_args("-m", "verify")
587
+ subject.run(options)
588
+ end
589
+
496
590
  describe "#run" do
497
591
  context "when successful" do #successful means exit(0)
498
592
  context "without any errors" do
499
593
  it "returns true" do
500
594
  mock_output(:stdout => "stdout.success", :stderr => "stderr.info")
501
- subject.run(options).should be_true
595
+ expect(subject.run(options)).to be true
502
596
  end
503
597
  end
504
598
 
@@ -506,7 +600,7 @@ describe ITunes::Store::Transporter::Command::Verify do
506
600
  it "raises an ExecutionError" do
507
601
  # If no packages were verfied it exits with 0 but emits an error message
508
602
  mock_output(:exit => 0, :stderr => "stderr.errors");
509
- lambda { subject.run(options) }.should raise_exception(ITunes::Store::Transporter::ExecutionError)
603
+ expect { subject.run(options) }.to raise_exception(ITunes::Store::Transporter::ExecutionError)
510
604
  end
511
605
  end
512
606
  end
@@ -1,29 +1,61 @@
1
1
  vendor_id_123123: |
2
- Vendor identifier: 123123
3
- Apple identifier: 123123
4
- iTunesConnect Status: Not ready for sale
2
+ <?xml version="1.0" encoding="UTF-8"?>
3
+ <itunes_transporter>
4
+ <upload_status apple_identifier="X9123X" vendor_identifier="123123">
5
+ <content_status_info content_review_status="Ready-NotReviewed" content_status="Unpolished" itunes_connect_status="Other">
6
+ <store_status not_on_store="N/A" on_store="N/A" ready_for_store="US"/>
7
+ <video_components>
8
+ <video_component component_delivered="2011-11-30 01:41:10" component_locale="N/A" component_name="Video" component_status="In Review"/>
9
+ <video_component component_delivered="2011-11-30 01:41:10" component_locale="en-US" component_name="Audio" component_status="In Review"/>
10
+ </video_components>
11
+ </content_status_info>
12
+ <upload_status_info created="2016-11-25 10:38:09" status="Imported"/>
13
+ </upload_status>
14
+ </itunes_transporter>
5
15
 
6
- -------------------------Status Info-------------------------
7
- Upload created: 2000-01-01 00:00:00
8
- Upload state: Uploaded
9
- Upload state id: 1
10
- Content state: Irie
11
- Content state id: 2
16
+ vendor_id_123134_failed: |
17
+ <?xml version="1.0" encoding="UTF-8"?>
18
+ <itunes_transporter>
19
+ <upload_status vendor_identifier="98143907070932">
20
+ <upload_status_info created="2014-08-14 15:09:26" status="Upload Failed"/>
21
+ </upload_status>
22
+ </itunes_transporter>
12
23
 
13
- vendor_id_789789: |
14
- Vendor identifier: 789789
24
+ vendor_id_123123_and_ABCABC: |
25
+ <?xml version="1.0" encoding="UTF-8"?>
26
+ <itunes_transporter>
27
+ <upload_status apple_identifier="X9123X" vendor_identifier="123123">
28
+ <content_status_info content_review_status="Ready-NotReviewed" content_status="Unpolished" itunes_connect_status="Other">
29
+ <store_status not_on_store="N/A" on_store="N/A" ready_for_store="US"/>
30
+ <video_components>
31
+ <video_component component_delivered="2011-11-30 01:41:10" component_locale="N/A" component_name="Video" component_status="In Review"/>
32
+ <video_component component_delivered="2011-11-30 01:41:10" component_locale="en-US" component_name="Audio" component_status="In Review"/>
33
+ </video_components>
34
+ </content_status_info>
35
+ <upload_status_info created="2016-11-25 10:38:09" status="Imported"/>
36
+ </upload_status>
37
+ <upload_status apple_identifier="919191" vendor_identifier="ABCABC">
38
+ <content_status_info content_review_status="Ready-NotReviewed" content_status="Unpolished" itunes_connect_status="Other">
39
+ <store_status not_on_store="N/A" on_store="US,MX" ready_for_store="US"/>
40
+ <video_components>
41
+ <video_component component_delivered="2016-11-25 12:92:46" component_locale="World" component_name="Preview Film" component_status="Approved"/>
42
+ <video_component component_delivered="2016-11-25 12:11:07" component_locale="en-US" component_name="Audio" component_status="Approved"/>
43
+ <video_component component_delivered="2016-11-25 12:12:46" component_locale="en-US" component_name="Chapters" component_status="Approved"/>
44
+ </video_components>
45
+ </content_status_info>
46
+ <upload_status_info created="2011-08-25 10:50:09" status="Imported"/>
47
+ <upload_status_info created="2012-11-08 08:26:11" status="Imported"/>
48
+ <upload_status_info created="2013-10-31 05:55:29" status="Imported"/>
49
+ <upload_status_info created="2014-11-25 10:38:09" status="Imported"/>
50
+ </upload_status>
51
+ </itunes_transporter>
15
52
 
16
- -------------------------Status Info-------------------------
17
- Upload created: 2000-01-01 00:00:00
18
- Upload state: Uploaded
19
- Upload state id: 1
20
- Content state: Irie
21
- Content state id: 2
22
53
 
23
- -------------------------Status Info #2-------------------------
24
- Upload created: 2000-01-02 00:00:00
25
- Upload state: Some Failure
26
- Upload state id: 2
27
- Content state: Still Irie
28
- Content state id: 3
54
+ error_message: |
55
+ <itunes_transporter a="foo">
29
56
 
57
+ Error Summary
58
+
59
+ Error message one. (-1234)
60
+ Error message two. (9999)
61
+ </itunes_transporter>