mms2r 1.1.12 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +32 -2
- data/Manifest.txt +41 -79
- data/README.txt +50 -51
- data/Rakefile +3 -2
- data/conf/aliases.yml +8 -0
- data/conf/message.alltel.com.yml +14 -0
- data/conf/messaging.nextel.com.yml +10 -0
- data/conf/mms.att.net.yml +9 -0
- data/conf/mms.dobson.net.yml +4 -0
- data/conf/mms.luxgsm.lu.yml +8 -0
- data/conf/mms.myhelio.com.yml +12 -0
- data/conf/mms.netcom.no.yml +4 -0
- data/conf/mms.o2online.de.yml +8 -0
- data/conf/mms.three.co.uk.yml +15 -0
- data/conf/mms2r_media.yml +6 -0
- data/conf/orangemms.net.yml +13 -0
- data/conf/pm.sprint.com.yml +10 -0
- data/conf/pxt.vodafone.net.nz.yml +5 -0
- data/conf/tmomail.net.yml +16 -0
- data/conf/vzwpix.com.yml +8 -0
- data/dev_tools/anonymizer.rb +20 -0
- data/lib/mms2r.rb +19 -45
- data/lib/mms2r/media.rb +288 -300
- data/lib/mms2r/media/sprint.rb +189 -0
- data/test/fixtures/att-text-01.mail +27 -0
- data/test/fixtures/helio-image-01.mail +8 -8
- data/test/fixtures/helio-message-01.mail +327 -0
- data/test/fixtures/luxgsm-image-01.mail +388 -0
- data/test/fixtures/netcom-image-01.mail +556 -0
- data/test/fixtures/o2-de-image-01.mail +314 -0
- data/test/fixtures/orange-uk-image-01.mail +71 -0
- data/test/fixtures/pxt-image-01.mail +118 -0
- data/test/fixtures/sprint-broken-image-01.mail +1 -1
- data/test/fixtures/sprint-image-01.mail +211 -195
- data/test/fixtures/sprint-purged-image-01.mail +1 -1
- data/test/fixtures/sprint-two-images-01.mail +231 -198
- data/test/fixtures/sprint-video-01.mail +210 -195
- data/test/fixtures/three-uk-image-01.mail +1202 -0
- data/test/test_helper.rb +39 -0
- data/test/{test_mms2r_alltel_media.rb → test_message_alltel_com.rb} +13 -17
- data/test/{test_mms2r_nextel_media.rb → test_messaging_nextel_com.rb} +12 -19
- data/test/{test_mms2r_sprint_pcs_media.rb → test_messaging_sprintpcs_com.rb} +9 -10
- data/test/test_mms2r_media.rb +474 -316
- data/test/test_mms_att_net.rb +92 -0
- data/test/test_mms_dobson_net.rb +41 -0
- data/test/test_mms_luxgsm_lu.rb +50 -0
- data/test/test_mms_myhelio_com.rb +60 -0
- data/test/test_mms_netcom_no.rb +52 -0
- data/test/test_mms_o2online_de.rb +53 -0
- data/test/test_mms_three_co_uk.rb +42 -0
- data/test/test_orangemms_net.rb +100 -0
- data/test/test_pm_sprint_com.rb +201 -0
- data/test/test_pxt_vodafone_net_nz.rb +37 -0
- data/test/{test_mms2r_t_mobile_media.rb → test_tmomail_net.rb} +8 -19
- data/test/{test_mms2r_verizon_media.rb → test_vzwpix_com.rb} +34 -27
- data/vendor/plugins/mms2r/lib/autotest/mms2r.rb +16 -11
- metadata +128 -157
- data/conf/mms2r_alltel_media_ignore.yml +0 -13
- data/conf/mms2r_att_media_subject.yml +0 -3
- data/conf/mms2r_cingular_me_media_subject.yml +0 -3
- data/conf/mms2r_cingular_me_media_transform.yml +0 -7
- data/conf/mms2r_dobson_media_ignore.yml +0 -4
- data/conf/mms2r_helio_media_ignore.yml +0 -6
- data/conf/mms2r_media_ignore.yml +0 -5
- data/conf/mms2r_media_subject.yml +0 -3
- data/conf/mms2r_my_cingular_media_subject.yml +0 -3
- data/conf/mms2r_nextel_media_ignore.yml +0 -11
- data/conf/mms2r_orange_france_media_ignore.yml +0 -6
- data/conf/mms2r_orange_poland_media_subject.yml +0 -3
- data/conf/mms2r_sprint_media_ignore.yml +0 -7
- data/conf/mms2r_sprint_media_subject.yml +0 -3
- data/conf/mms2r_t_mobile_media_ignore.yml +0 -16
- data/conf/mms2r_verizon_media_ignore.yml +0 -4
- data/conf/mms2r_verizon_media_transform.yml +0 -5
- data/lib/mms2r/alltel_media.rb +0 -10
- data/lib/mms2r/att_media.rb +0 -13
- data/lib/mms2r/cingular_me_media.rb +0 -23
- data/lib/mms2r/dobson_media.rb +0 -13
- data/lib/mms2r/helio_media.rb +0 -20
- data/lib/mms2r/m_mode_media.rb +0 -13
- data/lib/mms2r/my_cingular_media.rb +0 -15
- data/lib/mms2r/nextel_media.rb +0 -17
- data/lib/mms2r/orange_france_media.rb +0 -10
- data/lib/mms2r/orange_poland_media.rb +0 -10
- data/lib/mms2r/sprint_media.rb +0 -182
- data/lib/mms2r/sprint_pcs_media.rb +0 -16
- data/lib/mms2r/t_mobile_media.rb +0 -21
- data/lib/mms2r/verizon_media.rb +0 -19
- data/lib/mms2r/vtext_media.rb +0 -16
- data/lib/vendor/text/format.rb +0 -1466
- data/lib/vendor/tmail.rb +0 -3
- data/lib/vendor/tmail/address.rb +0 -242
- data/lib/vendor/tmail/attachments.rb +0 -39
- data/lib/vendor/tmail/base64.rb +0 -71
- data/lib/vendor/tmail/config.rb +0 -69
- data/lib/vendor/tmail/encode.rb +0 -467
- data/lib/vendor/tmail/facade.rb +0 -552
- data/lib/vendor/tmail/header.rb +0 -914
- data/lib/vendor/tmail/info.rb +0 -35
- data/lib/vendor/tmail/loader.rb +0 -1
- data/lib/vendor/tmail/mail.rb +0 -447
- data/lib/vendor/tmail/mailbox.rb +0 -433
- data/lib/vendor/tmail/mbox.rb +0 -1
- data/lib/vendor/tmail/net.rb +0 -280
- data/lib/vendor/tmail/obsolete.rb +0 -135
- data/lib/vendor/tmail/parser.rb +0 -1522
- data/lib/vendor/tmail/port.rb +0 -377
- data/lib/vendor/tmail/quoting.rb +0 -131
- data/lib/vendor/tmail/scanner.rb +0 -41
- data/lib/vendor/tmail/scanner_r.rb +0 -263
- data/lib/vendor/tmail/stringio.rb +0 -277
- data/lib/vendor/tmail/tmail.rb +0 -1
- data/lib/vendor/tmail/utils.rb +0 -238
- data/test/fixtures/broken_from_spam.mail +0 -80
- data/test/fixtures/hello_world_empty_text.mail +0 -7
- data/test/fixtures/hello_world_mail_multipart.mail +0 -24
- data/test/fixtures/hello_world_mail_plain_no_content_type.mail +0 -7
- data/test/fixtures/hello_world_mail_plain_with_content_type.mail +0 -8
- data/test/fixtures/simple-with-two-images-two-texts.mail +0 -49
- data/test/fixtures/simple_image.mail +0 -19
- data/test/fixtures/simple_multipart_alternative.mail +0 -42
- data/test/test_mms2r_att_media.rb +0 -54
- data/test/test_mms2r_cingular_me_media.rb +0 -51
- data/test/test_mms2r_dobson_media.rb +0 -46
- data/test/test_mms2r_helio_media.rb +0 -49
- data/test/test_mms2r_m_mode_media.rb +0 -36
- data/test/test_mms2r_my_cingular_media.rb +0 -31
- data/test/test_mms2r_orange_france_media.rb +0 -53
- data/test/test_mms2r_orange_poland_media.rb +0 -42
- data/test/test_mms2r_sprint_media.rb +0 -269
- data/test/test_mms2r_vtext_media.rb +0 -28
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsAttNet < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_mms_att_net
|
13
|
+
# mms.att.net service
|
14
|
+
mail = TMail::Mail.parse(load_mail('att-image-01.mail').join)
|
15
|
+
mms = MMS2R::Media.new(mail)
|
16
|
+
|
17
|
+
assert_equal 1, mms.media.size
|
18
|
+
assert_not_nil mms.media['image/jpeg']
|
19
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
20
|
+
assert_not_nil mms.media['image/jpeg'].first
|
21
|
+
assert_match(/Photo_12.jpg$/, mms.media['image/jpeg'][0])
|
22
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
23
|
+
mms.purge
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_mms_att_net_subject
|
27
|
+
# mms.att.net service
|
28
|
+
|
29
|
+
mail = TMail::Mail.parse(load_mail('att-image-02.mail').join)
|
30
|
+
mms = MMS2R::Media.new(mail)
|
31
|
+
|
32
|
+
assert_equal "", mms.subject
|
33
|
+
mms.purge
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_txt_att_net
|
37
|
+
# txt.att.net service
|
38
|
+
mail = TMail::Mail.parse(load_mail('att-text-01.mail').join)
|
39
|
+
mms = MMS2R::Media.new(mail)
|
40
|
+
|
41
|
+
assert_equal 1, mms.media.size
|
42
|
+
assert_not_nil(mms.media['text/plain'])
|
43
|
+
assert_equal "Hello World", IO.read(mms.media['text/plain'][0])
|
44
|
+
|
45
|
+
mms.purge
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_cingularme_com
|
49
|
+
# cingularme.com service
|
50
|
+
mail = TMail::Mail.parse(load_mail('cingularme-text-01.mail').join)
|
51
|
+
mms = MMS2R::Media.new(mail)
|
52
|
+
|
53
|
+
assert_equal 1, mms.media.size
|
54
|
+
assert_not_nil(mms.media['text/plain'])
|
55
|
+
assert_equal "hello world", IO.read(mms.media['text/plain'][0])
|
56
|
+
|
57
|
+
mms.purge
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_mmode_com
|
61
|
+
# mmode.com service
|
62
|
+
mail = TMail::Mail.parse(load_mail('mmode-image-01.mail').join)
|
63
|
+
mms = MMS2R::Media.new(mail)
|
64
|
+
|
65
|
+
assert_equal 1, mms.media.size
|
66
|
+
assert_not_nil mms.media['image/jpeg']
|
67
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
68
|
+
assert_not_nil mms.media['image/jpeg'].first
|
69
|
+
assert_match(/picture\(3\).jpg$/, mms.media['image/jpeg'][0])
|
70
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
71
|
+
mms.purge
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_mms_mycingular_com
|
75
|
+
# mms.mycingular.com service
|
76
|
+
mail = TMail::Mail.parse(load_mail('mycingular-image-01.mail').join)
|
77
|
+
mms = MMS2R::Media.new(mail)
|
78
|
+
|
79
|
+
assert_equal 2, mms.media.size
|
80
|
+
assert_not_nil mms.media['text/plain']
|
81
|
+
assert_not_nil mms.media['text/plain'][0]
|
82
|
+
assert_equal 1, mms.media['text/plain'].size
|
83
|
+
assert_not_nil mms.media['image/jpeg']
|
84
|
+
assert_not_nil mms.media['image/jpeg'][0]
|
85
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
86
|
+
assert_not_nil mms.media['image/jpeg'].first
|
87
|
+
assert_match(/04-18-07_1723.jpg$/, mms.media['image/jpeg'][0])
|
88
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
89
|
+
assert_equal "Water", IO.read(mms.media['text/plain'][0])
|
90
|
+
mms.purge
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsDobsonNet < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_mms_dobson_net
|
13
|
+
# mms.dobson.net service
|
14
|
+
mail = TMail::Mail.parse(load_mail('dobson-image-01.mail').join)
|
15
|
+
mms = MMS2R::Media.new(mail)
|
16
|
+
|
17
|
+
assert_equal 2, mms.media.size
|
18
|
+
|
19
|
+
assert_not_nil mms.media['image/jpeg']
|
20
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
21
|
+
assert_not_nil mms.media['image/jpeg'].first
|
22
|
+
assert_match(/04-18-07_1723.jpg$/, mms.media['image/jpeg'][0])
|
23
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
24
|
+
|
25
|
+
assert_equal nil, mms.media['application/smil'] # dobson phones have weird SMIL that can be ignored.
|
26
|
+
assert_not_nil(mms.media['text/plain'])
|
27
|
+
assert_equal 1, mms.media['text/plain'].size
|
28
|
+
assert_equal "Body", IO.read(mms.media['text/plain'][0])
|
29
|
+
|
30
|
+
mms.purge
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_body_should_return_user_text
|
34
|
+
mail = TMail::Mail.parse(load_mail('dobson-image-01.mail').join)
|
35
|
+
mms = MMS2R::Media.new(mail)
|
36
|
+
|
37
|
+
assert_equal 'Body', mms.body
|
38
|
+
|
39
|
+
mms.purge
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsLuxgsmLu < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_subject
|
13
|
+
mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
|
14
|
+
mms = MMS2R::Media.new(mail)
|
15
|
+
assert_equal "MMS2R - LUXGSM", mms.subject
|
16
|
+
|
17
|
+
mms.purge
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_image
|
21
|
+
mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
|
22
|
+
mms = MMS2R::Media.new(mail)
|
23
|
+
|
24
|
+
assert_equal 1, mms.media.size
|
25
|
+
assert_equal 2, mms.media['image/gif'].size
|
26
|
+
|
27
|
+
mms.purge
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_default_media_should_return_user_generated_content
|
31
|
+
mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
|
32
|
+
mms = MMS2R::Media.new(mail)
|
33
|
+
file = mms.default_media
|
34
|
+
assert_equal 8897, file.size
|
35
|
+
|
36
|
+
mms.purge
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_default_text_should_return_user_generated_content
|
40
|
+
mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
|
41
|
+
mms = MMS2R::Media.new(mail)
|
42
|
+
file = mms.default_text
|
43
|
+
assert_nil file
|
44
|
+
|
45
|
+
# TODO need more fixtures to handle text tests
|
46
|
+
|
47
|
+
mms.purge
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsMyhelioCom < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_only_valid_content_should_be_retained_for_mms_with_image_and_text
|
13
|
+
mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
|
14
|
+
mms = MMS2R::Media.new(mail)
|
15
|
+
assert_equal 2, mms.media.size
|
16
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
17
|
+
assert_equal 1, mms.media['text/plain'].size
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_only_valid_content_should_be_retained_for_mms_with_text
|
21
|
+
mail = TMail::Mail.parse(load_mail('helio-message-01.mail').join)
|
22
|
+
mms = MMS2R::Media.new(mail)
|
23
|
+
assert_equal 1, mms.media.size
|
24
|
+
assert_equal 1, mms.media['text/plain'].size
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_number_should_return_correct_number
|
28
|
+
mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
|
29
|
+
mms = MMS2R::Media.new(mail)
|
30
|
+
number = mms.number()
|
31
|
+
assert_equal number, 5551234.to_s
|
32
|
+
mms.purge
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_subject_should_return_correct_subject
|
36
|
+
mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
|
37
|
+
mms = MMS2R::Media.new(mail)
|
38
|
+
title = mms.subject()
|
39
|
+
assert_equal title, "Test image"
|
40
|
+
mms.purge
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_body_should_return_correct_body
|
44
|
+
mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
|
45
|
+
mms = MMS2R::Media.new(mail)
|
46
|
+
body = mms.body()
|
47
|
+
assert_equal body, "Test image"
|
48
|
+
mms.purge
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_attachment_should_return_jpeg
|
52
|
+
mail = TMail::Mail.parse(load_mail('helio-image-01.mail').join)
|
53
|
+
mms = MMS2R::Media.new(mail)
|
54
|
+
image = mms.default_media()
|
55
|
+
assert_not_nil mms.media['image/jpeg'][0]
|
56
|
+
assert_match(/0628070005.jpg$/, mms.media['image/jpeg'][0])
|
57
|
+
mms.purge
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsNetcomNo < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_subject
|
13
|
+
mail = TMail::Mail.parse(load_mail('netcom-image-01.mail').join)
|
14
|
+
mms = MMS2R::Media.new(mail)
|
15
|
+
assert_equal "Morning greetings from norway. This is a", mms.subject
|
16
|
+
|
17
|
+
mms.purge
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_image
|
21
|
+
mail = TMail::Mail.parse(load_mail('netcom-image-01.mail').join)
|
22
|
+
mms = MMS2R::Media.new(mail)
|
23
|
+
|
24
|
+
assert_equal 2, mms.media.size
|
25
|
+
assert_not_nil mms.media['text/plain']
|
26
|
+
assert_equal 1, mms.media['text/plain'].size
|
27
|
+
assert_not_nil mms.media['image/jpeg']
|
28
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
29
|
+
assert_file_size mms.media['image/jpeg'].first, 28471
|
30
|
+
|
31
|
+
mms.purge
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_default_media_should_return_user_generated_content
|
35
|
+
mail = TMail::Mail.parse(load_mail('netcom-image-01.mail').join)
|
36
|
+
mms = MMS2R::Media.new(mail)
|
37
|
+
file = mms.default_media
|
38
|
+
assert_equal 28471, file.size
|
39
|
+
|
40
|
+
mms.purge
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_default_text_should_return_user_generated_content
|
44
|
+
mail = TMail::Mail.parse(load_mail('netcom-image-01.mail').join)
|
45
|
+
mms = MMS2R::Media.new(mail)
|
46
|
+
file = mms.default_text
|
47
|
+
assert_equal "Morning greetings from norway. This is a mms from norwegian carrier netcom.", file.read
|
48
|
+
|
49
|
+
mms.purge
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsO2onlineDe < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_subject
|
13
|
+
mail = TMail::Mail.parse(load_mail('o2-de-image-01.mail').join)
|
14
|
+
mms = MMS2R::Media.new(mail)
|
15
|
+
assert_equal "this is a subject", mms.subject
|
16
|
+
mms.purge
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_image
|
20
|
+
mail = TMail::Mail.parse(load_mail('o2-de-image-01.mail').join)
|
21
|
+
mms = MMS2R::Media.new(mail)
|
22
|
+
|
23
|
+
# o2 is ungly, you cant' tel the logo is different than user content by its file name
|
24
|
+
assert_equal 2, mms.media.size
|
25
|
+
assert_not_nil mms.media['text/plain']
|
26
|
+
assert_equal 1, mms.media['text/plain'].size
|
27
|
+
assert_not_nil mms.media['image/jpeg']
|
28
|
+
assert_equal 2, mms.media['image/jpeg'].size
|
29
|
+
assert mms.media['image/jpeg'].detect{|f| File.size(f) == 10638}
|
30
|
+
|
31
|
+
mms.purge
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_default_media_should_return_user_generated_content
|
35
|
+
mail = TMail::Mail.parse(load_mail('o2-de-image-01.mail').join)
|
36
|
+
mms = MMS2R::Media.new(mail)
|
37
|
+
file = mms.default_media
|
38
|
+
assert_equal 10638, file.size
|
39
|
+
|
40
|
+
mms.purge
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_default_text_should_return_user_generated_content
|
44
|
+
mail = TMail::Mail.parse(load_mail('o2-de-image-01.mail').join)
|
45
|
+
mms = MMS2R::Media.new(mail)
|
46
|
+
file = mms.default_text
|
47
|
+
#assert_equal 42, file.size
|
48
|
+
assert_equal "This is text before the image. Thank you!\n", file.read
|
49
|
+
|
50
|
+
mms.purge
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestMmsThreeCoUk < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_subject
|
13
|
+
mail = TMail::Mail.parse(load_mail('three-uk-image-01.mail').join)
|
14
|
+
mms = MMS2R::Media.new(mail)
|
15
|
+
assert_equal "", mms.subject
|
16
|
+
|
17
|
+
mms.purge
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_image
|
21
|
+
mail = TMail::Mail.parse(load_mail('three-uk-image-01.mail').join)
|
22
|
+
mms = MMS2R::Media.new(mail)
|
23
|
+
|
24
|
+
assert_equal 1, mms.media.size
|
25
|
+
assert_not_nil mms.media['image/jpeg']
|
26
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
27
|
+
assert_match(/17102007.jpg$/, mms.media['image/jpeg'].first)
|
28
|
+
assert_file_size mms.media['image/jpeg'].first, 29908
|
29
|
+
|
30
|
+
mms.purge
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_default_media_should_return_user_generated_content
|
34
|
+
mail = TMail::Mail.parse(load_mail('three-uk-image-01.mail').join)
|
35
|
+
mms = MMS2R::Media.new(mail)
|
36
|
+
file = mms.default_media
|
37
|
+
assert_equal '17102007.jpg', file.original_filename
|
38
|
+
|
39
|
+
mms.purge
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
gem 'tmail', '>= 1.2.1'
|
7
|
+
require 'tmail'
|
8
|
+
|
9
|
+
class TestOrangemmsNet < Test::Unit::TestCase
|
10
|
+
include MMS2R::TestHelper
|
11
|
+
|
12
|
+
def test_orangemms_subject
|
13
|
+
# orangemms.net service
|
14
|
+
mail = TMail::Mail.parse(load_mail('orange-uk-image-01.mail').join)
|
15
|
+
mms = MMS2R::Media.new(mail)
|
16
|
+
assert_equal "", mms.subject
|
17
|
+
mms.purge
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_orangemms_image
|
21
|
+
# orangemms.net service
|
22
|
+
mail = TMail::Mail.parse(load_mail('orange-uk-image-01.mail').join)
|
23
|
+
mms = MMS2R::Media.new(mail)
|
24
|
+
|
25
|
+
assert_equal 1, mms.media.size
|
26
|
+
assert_nil mms.media['text/plain']
|
27
|
+
assert_nil mms.media['text/html']
|
28
|
+
assert_not_nil mms.media['image/jpeg'][0]
|
29
|
+
assert_match(/picture.jpg$/, mms.media['image/jpeg'][0])
|
30
|
+
|
31
|
+
assert_file_size mms.media['image/jpeg'][0], 337
|
32
|
+
|
33
|
+
mms.purge
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_orange_france_subject
|
37
|
+
# orange.fr service
|
38
|
+
mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
|
39
|
+
mms = MMS2R::Media.new(mail)
|
40
|
+
assert_equal "", mms.subject
|
41
|
+
mms.purge
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_orange_france_processed_content
|
45
|
+
# orange.fr service
|
46
|
+
mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
|
47
|
+
mms = MMS2R::Media.new(mail)
|
48
|
+
|
49
|
+
# there should be one text and one image
|
50
|
+
assert_equal 2, mms.media.size
|
51
|
+
|
52
|
+
#text
|
53
|
+
# there is a text banner that Orange attaches but
|
54
|
+
# that should be ignored
|
55
|
+
assert_not_nil mms.media['text/plain']
|
56
|
+
assert_equal 1, mms.media['text/plain'].size
|
57
|
+
file = mms.media['text/plain'].first
|
58
|
+
assert File::exist?(file), "file #{file} does not exist"
|
59
|
+
text = IO.readlines("#{file}").join
|
60
|
+
assert_match(/Test ma poule/, text)
|
61
|
+
|
62
|
+
# image
|
63
|
+
assert_not_nil mms.media['image/jpeg']
|
64
|
+
assert_equal 1, mms.media['image/jpeg'].size
|
65
|
+
assert_match(/IMAGE.jpeg$/, mms.media['image/jpeg'].first)
|
66
|
+
assert_file_size mms.media['image/jpeg'].first, 337
|
67
|
+
|
68
|
+
mms.purge
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_orange_poland_subject
|
72
|
+
# mmsemail.orange.pl service
|
73
|
+
mail = TMail::Mail.parse(load_mail('orangepoland-text-01.mail').join)
|
74
|
+
mms = MMS2R::Media.new(mail)
|
75
|
+
assert_equal "", mms.subject
|
76
|
+
mms.purge
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_orange_poland_non_empty_subject
|
80
|
+
# mmsemail.orange.pl service
|
81
|
+
mail = TMail::Mail.parse(load_mail('orangepoland-text-02.mail').join)
|
82
|
+
mms = MMS2R::Media.new(mail)
|
83
|
+
assert mms.subject, "whazzup"
|
84
|
+
mms.purge
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_orange_poland_content
|
88
|
+
# mmsemail.orange.pl service
|
89
|
+
mail = TMail::Mail.parse(load_mail('orangepoland-text-01.mail').join)
|
90
|
+
mms = MMS2R::Media.new(mail)
|
91
|
+
assert_not_nil mms.media['text/plain']
|
92
|
+
file = mms.media['text/plain'][0]
|
93
|
+
assert_not_nil file
|
94
|
+
assert File::exist?(file), "file #{file} does not exist"
|
95
|
+
text = IO.readlines("#{file}").join
|
96
|
+
assert_match(/pozdro600/, text)
|
97
|
+
mms.purge
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|