<commit_before>Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox']) do

  tests('success') do

    unless Fog.mocking?
      @server = Brightbox::Compute::TestSupport.get_test_server
      server_id = @server.id
    end

    create_options = {
      :name => "Fog@#{Time.now.iso8601}",
      :servers => [{
        :server => server_id
      }]
    }

    tests("#create_server_group(#{create_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].create_server_group(create_options)
      @server_group_id = result["id"]
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    tests("#list_server_groups") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].list_server_groups
      formats(Brightbox::Compute::Formats::Collection::SERVER_GROUPS) { result }
    end

    tests("#get_server_group('#{@server_group_id}')") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].get_server_group(@server_group_id)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    update_options = {:name => "Fog@#{Time.now.iso8601}"}
    tests("#update_server_group('#{@server_group_id}', #{update_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].update_server_group(@server_group_id, update_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    remove_options = {:servers => [{:server => server_id}]}
    tests("#remove_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    add_options = {:servers => [{:server => server_id}]}
    tests("#add_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].add_servers_server_group(@server_group_id, add_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    # Server Group must be empty to delete so we need to remove it again
    remove_options = {:servers => [{:server => server_id}]}
    tests("#remove_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    tests("#destroy_server_group('#{@server_group_id}')") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].destroy_server_group(@server_group_id)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    unless Fog.mocking?
      @server.destroy
    end

  end

  tests('failure') do

    tests("#create_server_group").raises(ArgumentError) do
      pending if Fog.mocking?
      Fog::Compute[:brightbox].create_server_group
    end
<commit_msg>[brightbox] Replace duplicate remove with move test<commit_after>Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox']) do

  tests('success') do

    unless Fog.mocking?
      @server = Brightbox::Compute::TestSupport.get_test_server
      server_id = @server.id
    end

    create_options = {
      :name => "Fog@#{Time.now.iso8601}",
      :servers => [{
        :server => server_id
      }]
    }

    tests("#create_server_group(#{create_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].create_server_group(create_options)
      @server_group_id = result["id"]
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    tests("#list_server_groups") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].list_server_groups
      formats(Brightbox::Compute::Formats::Collection::SERVER_GROUPS) { result }
      @default_group_id = result.select {|grp| grp["default"] == true }.first["id"]
    end

    tests("#get_server_group('#{@server_group_id}')") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].get_server_group(@server_group_id)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    update_options = {:name => "Fog@#{Time.now.iso8601}"}
    tests("#update_server_group('#{@server_group_id}', #{update_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].update_server_group(@server_group_id, update_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    remove_options = {:servers => [{:server => server_id}]}
    tests("#remove_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    add_options = {:servers => [{:server => server_id}]}
    tests("#add_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].add_servers_server_group(@server_group_id, add_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    move_options = {:destination => @default_group_id, :servers => [{:server => server_id}]}
    tests("#move_servers_server_group('#{@server_group_id}', #{move_options.inspect})") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].move_servers_server_group(@server_group_id, move_options)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
      test("group is emptied") { result["servers"].empty? }
    end

    tests("#destroy_server_group('#{@server_group_id}')") do
      pending if Fog.mocking?
      result = Fog::Compute[:brightbox].destroy_server_group(@server_group_id)
      formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
    end

    unless Fog.mocking?
      @server.destroy
    end

  end

  tests('failure') do

    tests("#create_server_group").raises(ArgumentError) do
      pending if Fog.mocking?
      Fog::Compute[:brightbox].create_server_group
    end

{'fraction_non_alphanumeric': 0.1454319453076445, 'fraction_numerical': 0.002486016159105034, 'mean_word_length': 4.464346349745331, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '5709074', 'n_tokens_mistral': 2083, 'n_tokens_neox': 2099, 'n_words': 312}