Sha256: 0499b2895e30123b4ba0afb6497a65203dab243355cd4ade397a7d31e88b6328

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require 'helper'
require 'multi_json'

class TestBlitline < Test::Unit::TestCase

  should "raise exception if missing jobs" do
    assert_raises RuntimeError do
      blitline = Blitline.new
      blitline.post_jobs
    end
  end

  should "raise exception if job missing application id" do
    assert_raises RuntimeError do
      blitline = Blitline.new
      blitline.jobs << Blitline::Job.new("http://ww.foo.com")
      blitline.post_jobs
    end
  end

  should "raise exception if job missing image identifier" do
    assert_raises RuntimeError do
      blitline = Blitline.new
      job =  Blitline::Job.new("http://ww.foo.com")
      job.application_id = "foo"
      job.add_function("blue", nil)
      blitline.jobs << job
      blitline.post_jobs
    end
  end

  should "raise exception if job missing image identifier" do
    assert_raises RuntimeError do
      blitline = Blitline.new
      job =  Blitline::Job.new("http://ww.foo.com")
      job.application_id = "foo"
      job.add_function("blur", nil, "my_image")
      blitline.jobs << job
      results = blitline.post_jobs
    end
  end

  should "properly jsonize the jsonizable_attributes" do
    job =  Blitline::Job.new("http://ww.foo.com")
    job.add_function("blue", nil, "my_image")
    job.application_id = "foo"
    job.add_jsonizable_attribute("pre_process", { "move_original" => { "s3_destination" => Blitline::S3Destination.new("my_key","my_bucket")}})

    results = MultiJson.dump(job)
    assert_not_nil results["pre_process"]
    assert results == '{"src":"http://ww.foo.com","functions":[{"name":"blue","save":{"image_identifier":"my_image"}}],"application_id":"foo","pre_process":{"move_original":{"s3_destination":{"key":"my_key","bucket":"my_bucket","headers":{}}}}}'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blitline-2.7.0 test/test_blitline.rb
blitline-2.6.0 test/test_blitline.rb
blitline-2.5.1 test/test_blitline.rb