<commit_before>require 'gooddata/models/schedule'

describe GoodData::Schedule do
  SCHEDULE_ID = ScheduleHelper::SCHEDULE_ID
  SCHEDULE_URL = "/gdc/projects/#{ProjectHelper::PROJECT_ID}/schedules/#{SCHEDULE_ID}"

  @test_cron = '0 15 27 7 *'

  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)

    @project_executable = './graph/graph.grf'

    @test_data = {
      :timezone => 'UTC',
      :cron => '2 2 2 2 *',
      :client => @client,
      :project => @project
    }

    @test_data_with_optional_param = {
      :timezone => 'UTC',
      :cron => '2 2 2 2 *',
      :reschedule => 15,
      :client => @client,
      :project => @project
    }
  end

  after(:each) do
    @client.disconnect
  end

  describe '#[]' do
    it 'Returns all schedules when :all passed' do
      res = @project.schedules
      res.should_not be_nil
      res.should be_a_kind_of(Array)
      res.each do |schedule|
        schedule.should be_a_kind_of(GoodData::Schedule)
      end
    end

    it 'Returns specific schedule when schedule ID passed' do
      res = @project.schedules(SCHEDULE_ID)
      res.should_not be_nil
      res.should be_a_kind_of(GoodData::Schedule)
    end

    it 'Returns specific schedule when schedule URL passed' do
      res = @project.schedules(SCHEDULE_ID)
      res.should_not be_nil
      res.should be_a_kind_of(GoodData::Schedule)
    end
  end

  describe '#all' do
    it 'Returns all schedules' do
      res = @project.schedules
      res.should_not be_nil
      res.should be_a_kind_of(Array)
      res.each do |schedule|
        schedule.should be_a_kind_of(GoodData::Schedule)
      end
    end
  end

  describe '#create' do
    it 'Creates new schedule if mandatory params passed' do
      sched = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, @project_executable, @test_data)
      }.not_to raise_error

      sched.should_not be_nil
      sched.delete
    end

    it 'Creates new schedule if mandatory params passed and optional params are present' do
      sched = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, @project_executable, @test_data_with_optional_param)
      }.not_to raise_error

      sched.should_not be_nil
      sched.delete
    end

    it 'Throws exception when no process ID specified' do
      expect {
        sched = @project.create_schedule(nil, @test_cron, @project_executable, @test_data)
      }.to raise_error 'Process ID has to be provided'
    end

    it 'Throws exception when no executable specified' do
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, nil, @test_data)
      }.to raise_error 'Executable has to be provided'
    end

    it 'Throws exception when no cron is specified' do
      data = @test_data.deep_dup
      data[:cron] = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, nil, @project_executable, data)
      }.to raise_error 'Cron schedule has to be provided'
    end<commit_msg>Fix expected exception in schedule no cron test<commit_after>require 'gooddata/models/schedule'

describe GoodData::Schedule do
  SCHEDULE_ID = ScheduleHelper::SCHEDULE_ID
  SCHEDULE_URL = "/gdc/projects/#{ProjectHelper::PROJECT_ID}/schedules/#{SCHEDULE_ID}"

  @test_cron = '0 15 27 7 *'

  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)

    @project_executable = './graph/graph.grf'

    @test_data = {
      :timezone => 'UTC',
      :cron => '2 2 2 2 *',
      :client => @client,
      :project => @project
    }

    @test_data_with_optional_param = {
      :timezone => 'UTC',
      :cron => '2 2 2 2 *',
      :reschedule => 15,
      :client => @client,
      :project => @project
    }
  end

  after(:each) do
    @client.disconnect
  end

  describe '#[]' do
    it 'Returns all schedules when :all passed' do
      res = @project.schedules
      res.should_not be_nil
      res.should be_a_kind_of(Array)
      res.each do |schedule|
        schedule.should be_a_kind_of(GoodData::Schedule)
      end
    end

    it 'Returns specific schedule when schedule ID passed' do
      res = @project.schedules(SCHEDULE_ID)
      res.should_not be_nil
      res.should be_a_kind_of(GoodData::Schedule)
    end

    it 'Returns specific schedule when schedule URL passed' do
      res = @project.schedules(SCHEDULE_ID)
      res.should_not be_nil
      res.should be_a_kind_of(GoodData::Schedule)
    end
  end

  describe '#all' do
    it 'Returns all schedules' do
      res = @project.schedules
      res.should_not be_nil
      res.should be_a_kind_of(Array)
      res.each do |schedule|
        schedule.should be_a_kind_of(GoodData::Schedule)
      end
    end
  end

  describe '#create' do
    it 'Creates new schedule if mandatory params passed' do
      sched = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, @project_executable, @test_data)
      }.not_to raise_error

      sched.should_not be_nil
      sched.delete
    end

    it 'Creates new schedule if mandatory params passed and optional params are present' do
      sched = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, @project_executable, @test_data_with_optional_param)
      }.not_to raise_error

      sched.should_not be_nil
      sched.delete
    end

    it 'Throws exception when no process ID specified' do
      expect {
        sched = @project.create_schedule(nil, @test_cron, @project_executable, @test_data)
      }.to raise_error 'Process ID has to be provided'
    end

    it 'Throws exception when no executable specified' do
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, @test_cron, nil, @test_data)
      }.to raise_error 'Executable has to be provided'
    end

    it 'Throws exception when no cron is specified' do
      data = @test_data.deep_dup
      data[:cron] = nil
      expect {
        sched = @project.create_schedule(ProcessHelper::PROCESS_ID, nil, @project_executable, data)
      }.to raise_error 'trigger schedule has to be provided'
    end
{'fraction_non_alphanumeric': 0.09269785745518146, 'fraction_numerical': 0.004664043142399067, 'mean_word_length': 3.0128654970760236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '344349', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2124, 'n_words': 546}