$: << File.dirname(__FILE__) + "/../lib" require 'rubygems' require 'crowdflower' require 'json' API_KEY = ENV["API_KEY"] DOMAIN_BASE = ENV["DOMAIN_BASE"] || "https://api.localdev.crowdflower.com:8443" unless API_KEY && API_KEY.size > 3 puts < true say "-- Waiting for CrowdFlower to finish copying the job." # You could also register a webhook to have CrowdFlower notify your # server. wait_until { job2.get["units_count"] == 8 } say "Checking the status of the job." assert job.status["tainted_judgments"] == 0 say "Adding title, instructions, and problem to the job." job.update({:title => 'testtt', :instructions => 'testttt fdsf sfds fsdfs fesfsdf', :cml => ''}) say "Registering a webhook." job.update :webhook_uri => "http://localhost:8080/crowdflower" say "Checking channels" assert !job.channels['available_channels'].empty? assert job.channels['enabled_channels'].empty? job.enable_channels ['amt'] assert job.channels['enabled_channels'] == ['amt'] job.enable_channels ['mob'] assert job.channels['enabled_channels'].sort == ['amt', 'mob'] job.enable_channels ['mob'] assert job.channels['enabled_channels'].sort == ['amt', 'mob'] say "Ordering the job." order = CrowdFlower::Order.new(job) unit_count = 8 order.debit(8) wait_until { job.get["state"].casecmp('running') == 0} say "Canceling the unit." unit_id = job.units.all.to_a[0][0] unit = CrowdFlower::Unit.new(job) wait_until { unit.get(unit_id)['state'] == 'judgable' } puts unit.cancel(unit_id).inspect assert unit.get(unit_id)['state'] == 'canceled' say "Webhook test needs to be written." #job.test_webhook say ">-< Tests complete. >-<"