## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true require 'spec_helper.rb' describe 'Sample' do it "can fetch" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() }.to raise_exception(Twilio::REST::TwilioError) expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://autopilot.twilio.com/v1/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Samples/UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives fetch responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples/UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assistant_sid": "UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "language": "language", "tagged_text": "tagged_text", "date_updated": "2015-07-30T20:00:00Z", "source_channel": null } ] )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() expect(actual).to_not eq(nil) end it "can read" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples.list() }.to raise_exception(Twilio::REST::TwilioError) expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://autopilot.twilio.com/v1/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Samples', ))).to eq(true) end it "receives read_empty responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "samples": [], "meta": { "first_page_url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples?Language=language&PageSize=50&Page=0", "previous_page_url": null, "key": "samples", "next_page_url": null, "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples?Language=language&PageSize=50&Page=0", "page": 0, "page_size": 50 } } ] )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples.list() expect(actual).to_not eq(nil) end it "receives read_full responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "samples": [ { "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples/UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assistant_sid": "UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "language": "language", "tagged_text": "tagged_text", "date_updated": "2015-07-30T20:00:00Z", "source_channel": "sms" } ], "meta": { "first_page_url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples?Language=language&PageSize=50&Page=0", "previous_page_url": null, "key": "samples", "next_page_url": null, "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples?Language=language&PageSize=50&Page=0", "page": 0, "page_size": 50 } } ] )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples.list() expect(actual).to_not eq(nil) end it "can create" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples.create(language: 'language', tagged_text: 'tagged_text') }.to raise_exception(Twilio::REST::TwilioError) values = {'Language' => 'language', 'TaggedText' => 'tagged_text', } expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://autopilot.twilio.com/v1/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Samples', data: values, ))).to eq(true) end it "receives create responses" do @holodeck.mock(Twilio::Response.new( 201, %q[ { "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples/UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assistant_sid": "UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "language": "language", "tagged_text": "tagged_text", "date_updated": "2015-07-30T20:00:00Z", "source_channel": "alexa" } ] )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples.create(language: 'language', tagged_text: 'tagged_text') expect(actual).to_not eq(nil) end it "can update" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() }.to raise_exception(Twilio::REST::TwilioError) expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://autopilot.twilio.com/v1/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Samples/UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives update responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "url": "https://autopilot.twilio.com/v1/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples/UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "UFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assistant_sid": "UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "language": "language", "tagged_text": "tagged_text", "date_updated": "2015-07-30T20:00:00Z", "source_channel": "alexa" } ] )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() expect(actual).to_not eq(nil) end it "can delete" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() }.to raise_exception(Twilio::REST::TwilioError) expect( @holodeck.has_request?(Holodeck::Request.new( method: 'delete', url: 'https://autopilot.twilio.com/v1/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Samples/UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives delete responses" do @holodeck.mock(Twilio::Response.new( 204, nil, )) actual = @client.autopilot.v1.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks('UDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .samples('UFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() expect(actual).to eq(true) end end