scaleapi-ruby 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ class TestCancelTask < Test::Unit::TestCase
9
9
  phone_number: '5055006865',
10
10
  entity_name: 'Alexandr Wang',
11
11
  fields: { email: 'Email Address' },
12
+ script: 'Hello ! Are you happy today? (pause) One more thing - what is your email address?',
12
13
  choices: ['He is happy', 'He is not happy']
13
14
 
14
15
  # Then, try canceling it
@@ -7,7 +7,11 @@ class TestCreateAnnotationTask < Test::Unit::TestCase
7
7
  attachment_type: "image",
8
8
  attachment: "http://i.imgur.com/v4cBreD.jpg",
9
9
  objects_to_annotate: ["baby cow", "big cow"],
10
- with_labels: true
10
+ with_labels: true,
11
+ examples: [
12
+ { correct: false, image: 'http://i.imgur.com/lj6e98s.jpg', explanation: 'The boxes are tight and accurate' },
13
+ { correct: true, image: 'http://i.imgur.com/HIrvIDq.jpg', explanation: 'The boxes are neither accurate nor complete' }
14
+ ]
11
15
 
12
16
  @invalid_parameters = Scale.hash
13
17
  end
@@ -16,7 +20,7 @@ class TestCreateAnnotationTask < Test::Unit::TestCase
16
20
  VCR.use_cassette 'tasks' do
17
21
  task = scale.create_annotation_task @valid_parameters
18
22
  assert_equal task.class, Scale::Resources::Task
19
- assert_equal task.params, @valid_parameters.select { |k| %Q(attachment_type attachment objects_to_annotate with_labels).include? k.to_s }
23
+ assert_equal task.params, @valid_parameters.select { |k| %Q(attachment_type attachment explanation objects_to_annotate examples with_labels).include? k.to_s }
20
24
  end
21
25
  end
22
26
 
@@ -33,7 +37,7 @@ class TestCreateAnnotationTask < Test::Unit::TestCase
33
37
  end
34
38
 
35
39
  assert_equal exception.code, 400
36
- assert_equal exception.message, 'Please provide a plaintext instruction to the worker in the instruction field.'
40
+ assert_equal exception.message, 'Please provide an attachment as a URL or plaintext.'
37
41
  end
38
42
  end
39
43
  end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ class TestCreateDataCollectionTask < Test::Unit::TestCase
4
+ context 'create a comparison task' do
5
+ setup do
6
+ @valid_parameters = Scale.hash callback_url: 'http://www.example.com/callback',
7
+ instruction: 'Find the URL for the hiring page for the company with attached website.',
8
+ attachment_type: 'website',
9
+ attachment: 'https://www.scaleapi.com/',
10
+ fields: { hiring_page: 'Hiring Page URL' }
11
+
12
+ @invalid_parameters = Scale.hash instruction: 'Test instruction',
13
+ fields: { hiring_page: 'Hiring Page URL' }
14
+ end
15
+
16
+ should 'create a valid data collection task' do
17
+ VCR.use_cassette 'tasks' do
18
+ task = scale.create_data_collection_task @valid_parameters
19
+ assert_equal task.class, Scale::Resources::Task
20
+ assert_equal task.params, @valid_parameters.select { |k| %Q(fields attachments attachment_type).include? k.to_s }
21
+ end
22
+ end
23
+
24
+ should 'raise a 400 (bad request) error with invalid parameters' do
25
+ VCR.use_cassette 'tasks' do
26
+ assert_raise Scale::HttpError do
27
+ scale.create_data_collection_task @invalid_parameters
28
+ end
29
+
30
+ begin
31
+ scale.create_data_collection_task @invalid_parameters
32
+ rescue => e
33
+ exception = e
34
+ end
35
+
36
+ assert_equal exception.code, 400
37
+ assert_equal exception.message, 'Invalid attachment_type - please choose one of these: text website'
38
+ end
39
+ end
40
+ end
41
+ end
@@ -7,6 +7,7 @@ class TestCreatePhonecallTask < Test::Unit::TestCase
7
7
  phone_number: '5055006865',
8
8
  entity_name: 'Alexandr Wang',
9
9
  fields: { email: 'Email Address' },
10
+ script: 'Hello ! Are you happy today? (pause) One more thing - what is your email address?',
10
11
  choices: ['He is happy', 'He is not happy']
11
12
 
12
13
  @invalid_parameters = Scale.hash instruction: 'Test instruction',
@@ -17,7 +18,7 @@ class TestCreatePhonecallTask < Test::Unit::TestCase
17
18
  VCR.use_cassette 'tasks' do
18
19
  task = scale.create_phonecall_task @valid_parameters
19
20
  assert_equal task.class, Scale::Resources::Task
20
- assert_equal task.params, @valid_parameters.select { |k| %Q(phone_number entity_name fields choices).include? k.to_s }
21
+ assert_equal task.params, @valid_parameters.select { |k| %Q(phone_number entity_name fields choices script).include? k.to_s }
21
22
  end
22
23
  end
23
24
 
@@ -5,7 +5,7 @@ class TestListTasks < Test::Unit::TestCase
5
5
  should 'retrieve a list of tasks' do
6
6
  VCR.use_cassette 'tasks' do
7
7
  tasks = scale.tasks
8
- assert_equal(tasks.class, Array)
8
+ assert_equal(tasks.class, Scale::Resources::Tasks)
9
9
  assert(tasks.count > 0)
10
10
  assert tasks.all? { |t| t.is_a? Scale::Resources::Task }
11
11
  end
@@ -9,6 +9,7 @@ class TestRetrieveTask < Test::Unit::TestCase
9
9
  phone_number: '5055006865',
10
10
  entity_name: 'Alexandr Wang',
11
11
  fields: { email: 'Email Address' },
12
+ script: 'Hello ! Are you happy today? (pause) One more thing - what is your email address?',
12
13
  choices: ['He is happy', 'He is not happy']
13
14
 
14
15
  # Retrieve that task, and compare it with the previous task
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaleapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Herzog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-21 00:00:00.000000000 Z
11
+ date: 2016-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -133,6 +133,7 @@ files:
133
133
  - lib/scale/endpoints/tasks/create_annotation_task.rb
134
134
  - lib/scale/endpoints/tasks/create_categorization_task.rb
135
135
  - lib/scale/endpoints/tasks/create_comparison_task.rb
136
+ - lib/scale/endpoints/tasks/create_data_collection_task.rb
136
137
  - lib/scale/endpoints/tasks/create_phonecall_task.rb
137
138
  - lib/scale/endpoints/tasks/create_transcription_task.rb
138
139
  - lib/scale/endpoints/tasks/list_tasks.rb
@@ -142,6 +143,8 @@ files:
142
143
  - lib/scale/http_error.rb
143
144
  - lib/scale/resources/base.rb
144
145
  - lib/scale/resources/task.rb
146
+ - lib/scale/resources/tasks.rb
147
+ - scaleapi-ruby.gemspec
145
148
  - test/callbacks/test_task_callback.rb
146
149
  - test/fixtures/callback.json
147
150
  - test/fixtures/vcr_cassettes/tasks.yml
@@ -150,6 +153,7 @@ files:
150
153
  - test/tasks/test_create_annotation_task.rb
151
154
  - test/tasks/test_create_categorization_task.rb
152
155
  - test/tasks/test_create_comparison_task.rb
156
+ - test/tasks/test_create_data_collection_task.rb
153
157
  - test/tasks/test_create_phonecall_task.rb
154
158
  - test/tasks/test_create_transcription_task.rb
155
159
  - test/tasks/test_list_tasks.rb