<commit_before>require File.join(File.dirname(__FILE__), '../spec_helper')

include Astute::Provision

describe Cobbler do
  include SpecHelpers



  it "should be able to be initialized with 'url'" do
    host = "host.domain.tld"
    port = "1234"
    path = "/api"
    username = 'user'
    password = '<PASSWORD>'

    remote = mock() do
      expects(:call).with('login', username, password)
    end
    tmp = XMLRPC::Client
    XMLRPC::Client = mock() do
      expects(:new).with(host, path, port).returns(remote)
    end
    Astute::Provision::Cobbler.new(
                               'url' => "http://#{host}:#{port}#{path}",
                               'username' => username,
                               'password' => password
                               )
    XMLRPC::Client = tmp
  end

  it "should be able to be initialized with 'host', 'port', 'path'" do
    host = "host.domain.tld"
    port = "1234"
    path = "/api"
    username = 'user'
    password = '<PASSWORD>'

    remote = mock() do
      expects(:call).with('login', username, password)
    end
    tmp = XMLRPC::Client
    XMLRPC::Client = mock() do
      expects(:new).with(host, path, port).returns(remote)
    end
    Astute::Provision::Cobbler.new(
                               'host' => host,
                               'port' => port,
                               'path' => path,
                               'username' => username,
                               'password' => password
                               )
    XMLRPC::Client = tmp
  end

  context "cobbler methods" do
    before(:each) do
      remote = mock() do
        stubs(:call)
        stubs(:call).with('login', 'cobbler', 'cobbler').returns('remotetoken')
      end
      @tmp = XMLRPC::Client
      XMLRPC::Client = mock() do
        stubs(:new).returns(remote)
      end

      @data = {
        'profile' => 'centos63-x86_64',
        'power_type' => 'ssh',
        'power_user' => 'root',
        'power_pass' => '/root/.ssh/bootstrap.rsa',
        'power-address' => '172.16.58.3',
        'hostname' => 'name.domain.tld',
        'name_servers' => '172.16.31.10 172.16.31.10',
        'name_servers_search' => 'some.domain.tld domain.tld',
        'netboot_enabled' => '1',
        'ks_meta' => 'some_param=1 another_param=2',
        'interfaces' => {
          'eth0' => {
            'mac_address' => '00:00:00:00:00:00',
            'static' => '1',<commit_msg>Fix spec for centos-6.4<commit_after>require File.join(File.dirname(__FILE__), '../spec_helper')

include Astute::Provision

describe Cobbler do
  include SpecHelpers



  it "should be able to be initialized with 'url'" do
    host = "host.domain.tld"
    port = "1234"
    path = "/api"
    username = 'user'
    password = '<PASSWORD>'

    remote = mock() do
      expects(:call).with('login', username, password)
    end
    tmp = XMLRPC::Client
    XMLRPC::Client = mock() do
      expects(:new).with(host, path, port).returns(remote)
    end
    Astute::Provision::Cobbler.new(
                               'url' => "http://#{host}:#{port}#{path}",
                               'username' => username,
                               'password' => password
                               )
    XMLRPC::Client = tmp
  end

  it "should be able to be initialized with 'host', 'port', 'path'" do
    host = "host.domain.tld"
    port = "1234"
    path = "/api"
    username = 'user'
    password = '<PASSWORD>'

    remote = mock() do
      expects(:call).with('login', username, password)
    end
    tmp = XMLRPC::Client
    XMLRPC::Client = mock() do
      expects(:new).with(host, path, port).returns(remote)
    end
    Astute::Provision::Cobbler.new(
                               'host' => host,
                               'port' => port,
                               'path' => path,
                               'username' => username,
                               'password' => password
                               )
    XMLRPC::Client = tmp
  end

  context "cobbler methods" do
    before(:each) do
      remote = mock() do
        stubs(:call)
        stubs(:call).with('login', 'cobbler', 'cobbler').returns('remotetoken')
      end
      @tmp = XMLRPC::Client
      XMLRPC::Client = mock() do
        stubs(:new).returns(remote)
      end

      @data = {
        'profile' => 'centos-x86_64',
        'power_type' => 'ssh',
        'power_user' => 'root',
        'power_pass' => '/root/.ssh/bootstrap.rsa',
        'power-address' => '172.16.58.3',
        'hostname' => 'name.domain.tld',
        'name_servers' => '172.16.31.10 172.16.31.10',
        'name_servers_search' => 'some.domain.tld domain.tld',
        'netboot_enabled' => '1',
        'ks_meta' => 'some_param=1 another_param=2',
        'interfaces' => {
          'eth0' => {
            'mac_address' => '00:00:00:00:00:00',
            'static' => '1',
{'fraction_non_alphanumeric': 0.15444172779136103, 'fraction_numerical': 0.023227383863080684, 'mean_word_length': 1.7486002239641658, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '2328394', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1507, 'n_words': 320}