Sha256: 81490cc7c85a5948a84b2420981de6e06cad4dc061cb34f3a5f99a35cf60eaaf

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require File.dirname(__FILE__) + "/test_helper"
require 'test/unit'
require 'rubygems'
require 'mms2r'
require 'mms2r/media'
require 'tmail/mail'
require 'logger'

class MMS2R::TMobileMediaTest < Test::Unit::TestCase
  include MMS2R::TestHelper

  def setup
    @log = Logger.new(STDOUT)
    @log.level = Logger::DEBUG
    @log.datetime_format = "%H:%M:%S"
  end

  def teardown; end

  def test_ignore_simple_image
    mail = TMail::Mail.parse(load_mail('tmobile-image-01.mail').join)
    mms = MMS2R::Media.create(mail)
    mms.process

    assert_equal 1, mms.media.size
    assert_nil mms.media['text/plain']
    assert_nil mms.media['text/html']
    assert_not_nil mms.media['image/jpeg'][0]
    assert_match(/12-01-06_1234.jpg$/, mms.media['image/jpeg'][0])

    assert_file_size mms.media['image/jpeg'][0], 337

    mms.purge
  end
  
  def test_message_with_body_text
    mail = TMail::Mail.parse(load_mail('tmobile-image-02.mail').join)
    mms = MMS2R::Media.create(mail)
    mms.process
    
    assert_equal 2, mms.media.size
    assert_not_nil mms.media['text/plain']
    assert_nil mms.media['text/html']
    assert_not_nil mms.media['image/jpeg'][0]
    assert_match(/07-25-05_0935.jpg$/, mms.media['image/jpeg'][0])
    
    assert_file_size mms.media['image/jpeg'][0], 337
    
    file = mms.media['text/plain'][0]
    assert_not_nil file
    assert File::exist?(file), "file #{file} does not exist"
    text = IO.readlines("#{file}").join
    assert_equal "Lillies", text.strip
    
    mms.purge
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mms2r-1.1.1 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.10 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.0 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.11 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.12 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.2 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.3 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.4 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.5 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.6 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.7 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.8 test/test_mms2r_t_mobile_media.rb
mms2r-1.1.9 test/test_mms2r_t_mobile_media.rb