Sha256: 12a05c859503eb74ae6e62f842c3c522d05dcf85b46b38003417dd817a172a52

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

load './helper.rb'
require 'prx/client'
require 'prx/model'
require 'net/http'

class PRX::TestPiece < Test::Unit::TestCase

  def test_initialize
    a = PRX::Model::Piece.new(:title=>'t', :id=>1)
    assert a.is_a?(PRX::Model::Piece)
    assert_equal a.title, 't'
    assert_equal a.id, 1
  end

  def test_initialize_with_account_json
    a = PRX::Model::Piece.from_json({:title=>'t', :id=>1, :account=>{:id=>2}}.to_json)
    assert a.account.is_a?(PRX::Model::Account)
  end

  def test_initialize_with_account_object
    a = PRX::Model::Piece.from_json({:title=>'t', :id=>1, :account=>PRX::Model::Account.new(:id=>2)})
    assert a.account.is_a?(PRX::Model::Account)
  end

  def test_piece_create_with_local_file
    p = PRX::Model::Piece.new(:title=>'test title')
    p.add_audio(:label=>'test', :attach_file=>'/Users/akuklewicz/test.mp2', :content_type=>'audio/mpeg')
    af = p.audio_versions[0].audio_files[0]
    assert af.is_a?(PRX::Model::AudioFile)
    assert af.attach_file.is_a?(Faraday::UploadIO)
  end

  def test_piece_create_with_remote_url
    p = PRX::Model::Piece.new(:title=>'test title')
    p.add_audio(:label=>'test', :attach_file=>'s3://andrew-s3.prx.org/test/test_short_download.mp3')
    af = p.audio_versions[0].audio_files[0]
    assert af.is_a?(PRX::Model::AudioFile)
    assert af.attach_file.is_a?(String)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prx_client-0.1.3 test/test_piece.rb
prx_client-0.1.2 test/test_piece.rb
prx_client-0.1.1 test/test_piece.rb
prx_client-0.1.0 test/test_piece.rb