spec/integration/schedule_spec.rb in gooddata-0.6.49 vs spec/integration/schedule_spec.rb in gooddata-0.6.50

- old
+ new

@@ -1,25 +1,18 @@ # encoding: UTF-8 # -# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved. +# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved. # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. require 'gooddata/models/schedule' require 'gooddata/helpers/global_helpers' describe GoodData::Schedule do SCHEDULE_ID = ScheduleHelper::SCHEDULE_ID SCHEDULE_URL = "/gdc/projects/#{ProjectHelper::PROJECT_ID}/schedules/#{SCHEDULE_ID}" - before(:all) do - @client = ConnectionHelper.create_default_connection - @project = ProjectHelper.get_default_project(:client => @client) - # ScheduleHelper.remove_old_schedules(@project) - # ProcessHelper.remove_old_processes(@project) - end - before(:each) do @client = ConnectionHelper.create_default_connection @project = ProjectHelper.get_default_project(:client => @client) @test_cron = '0 15 27 7 *' @@ -101,50 +94,50 @@ end it 'Throws exception when no process ID specified' do schedule = nil begin - expect { + expect do schedule = @project.create_schedule(nil, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data) - }.to raise_error 'Process ID has to be provided' + end.to raise_error 'Process ID has to be provided' ensure schedule && schedule.delete end end it 'Throws exception when no executable specified' do schedule = nil begin - expect { + expect do schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, nil, @test_data) - }.to raise_error 'Executable has to be provided' + end.to raise_error 'Executable has to be provided' ensure schedule && schedule.delete end end it 'Throws exception when no cron is specified' do data = GoodData::Helpers.deep_dup(@test_data) data[:cron] = nil schedule = nil begin - expect { + expect do schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, nil, ProcessHelper::DEPLOY_NAME, data) - }.to raise_error 'Trigger schedule has to be provided' + end.to raise_error 'Trigger schedule has to be provided' ensure schedule && schedule.delete end end it 'Throws exception when no timezone specified' do data = GoodData::Helpers.deep_dup(@test_data) schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, data) schedule.timezone = nil begin - expect { + expect do schedule.save - }.to raise_error 'A timezone has to be provided' + end.to raise_error 'A timezone has to be provided' ensure schedule && schedule.delete end end @@ -152,13 +145,13 @@ schedule = nil data = GoodData::Helpers.deep_dup(@test_data) begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, data) schedule.type = nil - expect { + expect do schedule.save - }.to raise_error 'Schedule type has to be provided' + end.to raise_error 'Schedule type has to be provided' ensure schedule && schedule.delete end end end @@ -223,13 +216,15 @@ end describe '#execute' do it 'Waits for execution result by default' do begin - process = @project.deploy_process('./spec/data/gooddata_version_process/gooddata_version.zip', - type: 'RUBY', - name: 'Test ETL zipped file GoodData Process') + process = @project.deploy_process( + './spec/data/gooddata_version_process/gooddata_version.zip', + type: 'RUBY', + name: 'Test ETL zipped file GoodData Process' + ) schedule = process.create_schedule('0 15 27 7 *', process.executables.first) res = schedule.execute expect(res).to be_an_instance_of(GoodData::Execution) expect([:ok, :error].include?(res.status)).to be_truthy ensure @@ -317,11 +312,11 @@ it 'Assigns the hidden parameter and marks the object dirty' do begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data) old_params = schedule.hidden_params - test_parameter = {'test_parameter' => 'just_testing' } + test_parameter = { 'test_parameter' => 'just_testing' } schedule.set_hidden_parameter(test_parameter.keys.first, test_parameter.values.first) expect(schedule.hidden_params).to eq(old_params.merge(test_parameter)) expect(schedule.dirty).to eq(true) ensure schedule && schedule.delete @@ -333,20 +328,19 @@ it 'Assigns the hidden parameter and marks the object dirty' do begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data) old_params = schedule.params - test_parameter = {'test_parameter' => 'just_testing' } + test_parameter = { 'test_parameter' => 'just_testing' } schedule.set_parameter(test_parameter.keys.first, test_parameter.values.first) expect(schedule.params).to eq(old_params.merge(test_parameter)) expect(schedule.dirty).to eq(true) ensure schedule && schedule.delete end end end - describe '#params' do it 'Should return execution params as hash' do begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data) @@ -362,11 +356,10 @@ describe '#params=' do it 'Assigns the params and marks the object dirty' do begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data) - old_params = schedule.params test_params = { 'some_new_param' => '1-2-3-4' } @@ -536,11 +529,11 @@ describe '#name' do it 'should be able to get name of the schedule.' do begin schedule = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, ProcessHelper::DEPLOY_NAME, @test_data_with_optional_param) - expect(schedule.name).to eq ProcessHelper::DEPLOY_NAME + expect("cc/graph/#{schedule.name}").to eq ProcessHelper::DEPLOY_NAME ensure schedule && schedule.delete end end @@ -585,11 +578,11 @@ describe '#name=' do it 'should be able to set name of the schedule.' do begin process = @project.processes(ProcessHelper::PROCESS_ID) schedule = process.create_schedule(@test_cron, ProcessHelper::DEPLOY_NAME, @test_data_with_optional_param) - expect(schedule.name).to eq ProcessHelper::DEPLOY_NAME + expect("cc/graph/#{schedule.name}").to eq ProcessHelper::DEPLOY_NAME schedule.name = 'MY NAME' schedule.save schedule2 = process.schedules.find { |s| s.obj_id == schedule.obj_id } expect(schedule2.name).to eq 'MY NAME' ensure @@ -600,23 +593,19 @@ describe '#disable' do it 'should preserve the hidden parmeters.' do begin process = @project.processes(ProcessHelper::PROCESS_ID) - schedule = process.create_schedule(@test_cron, ProcessHelper::DEPLOY_NAME, @test_data_with_optional_param.merge({hidden_params: { - "a" => { - "b" => "c" - } - }})) - + schedule = process.create_schedule( + @test_cron, + ProcessHelper::DEPLOY_NAME, + @test_data_with_optional_param.merge(hidden_params: { "a" => { "b" => "c" } }) + ) + schedule.save - expect(schedule.hidden_params).to eq({ - GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY => nil - }) + expect(schedule.hidden_params).to eq(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY => nil) schedule2 = process.schedules.find { |s| s.uri == schedule.uri } - expect(schedule2.to_update_payload['schedule']['hiddenParams']).to eq ({ - GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY => nil - }) + expect(schedule2.to_update_payload['schedule']['hiddenParams']).to eq(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY => nil) ensure schedule && schedule.delete end end end