<commit_before>require_relative './../../spec_helper'
require_relative './../../fixtures/fake_resource'

RSpec.describe OneviewCookbook::ResourceProvider do
  include_context 'shared context'

  let(:res) { described_class.new(FakeResource.new) }

  before :each do
    allow(OneviewCookbook::Helper).to receive(:build_client).and_return @client
    allow(OneviewCookbook::Helper).to receive(:build_image_streamer_client).and_return @i3s_client
    @context = FakeResource.new(client: { api_version: 200 })
  end

  describe '#initialize' do
    it 'sets all the necessary resource info as instance variables' do
      r = described_class.new(@context)
      expect(r.context).to eq(@context)
      expect(r.resource_name).to eq(@context.resource_name)
      expect(r.name).to eq(@context.name)
      expect(r.sdk_resource_type).to eq('Resource')
      expect(r.sdk_api_version).to eq(200)
      expect(r.sdk_variant).to eq(nil)
      expect(r.sdk_base_module).to eq(OneviewSDK)
      expect(r.item.client).to eq(@client)
      expect(r.item.data).to eq('name' => @context.name)
    end

    it "respects the resource's api_header_version property" do
      r = described_class.new(FakeResource.new(client: { api_version: 200 }))
      expect(r.item.api_version).to eq(200)
    end

    it "respects the resource's data property" do
      data = { 'name' => 'myname', 'key' => 'val', client: { api_version: 200 } }
      r = described_class.new(FakeResource.new(data: data))
      expect(r.item.data).to eq(data)
    end<commit_msg>fixed many UTs<commit_after>require_relative './../../spec_helper'
require_relative './../../fixtures/fake_resource'

RSpec.describe OneviewCookbook::ResourceProvider do
  include_context 'shared context'

  let(:res) { described_class.new(FakeResource.new(client: { api_version: 200 })) }

  before :each do
    allow(OneviewCookbook::Helper).to receive(:build_client).and_return @client
    allow(OneviewCookbook::Helper).to receive(:build_image_streamer_client).and_return @i3s_client
    @context = FakeResource.new(client: { api_version: 200 })
  end

  describe '#initialize' do
    it 'sets all the necessary resource info as instance variables' do
      r = described_class.new(@context)
      expect(r.context).to eq(@context)
      expect(r.resource_name).to eq(@context.resource_name)
      expect(r.name).to eq(@context.name)
      expect(r.sdk_resource_type).to eq('Resource')
      expect(r.sdk_api_version).to eq(nil)
      expect(r.sdk_variant).to eq(nil)
      expect(r.sdk_base_module).to eq(OneviewSDK)
      expect(r.item.client).to eq(@client)
      expect(r.item.data).to eq('name' => @context.name)
    end

    it "respects the resource's api_header_version property" do
      r = described_class.new(FakeResource.new(client: { api_version: 200 }))
      expect(r.item.api_version).to eq(200)
    end

    it "respects the resource's data property" do
      data = { 'name' => 'myname', 'key' => 'val' }
      r = described_class.new(FakeResource.new(data: data, client: { api_version: 200 }))
      expect(r.item.data).to eq(data)
    end
{'fraction_non_alphanumeric': 0.13634894991922455, 'fraction_numerical': 0.010339256865912763, 'mean_word_length': 3.8602825745682887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2881226', 'n_tokens_mistral': 1039, 'n_tokens_neox': 988, 'n_words': 197}