<commit_before>require 'spec_helper'

describe ManageEngine::AppManager::Api::Version11 do
  subject { ManageEngine::AppManager::Api::Version11 }

  describe "connect_path" do
    it "returns the connect_path for AppManager" do
      FactoryGirl.build(:api, :version => "11").connect_path.should be_instance_of(String)
    end
  end

  describe "connect_response_valid?" do
    let(:api)              { FactoryGirl.build :api, :version => "11" }
    let(:valid_response)   { File.open(File.dirname(__FILE__) + "/../../fixtures/valid_connect.xml", "r").read }
    let(:invalid_response) { File.open(File.dirname(__FILE__) + "/../../fixtures/invalid_connect.xml", "r").read }
    let(:non_xml)          { "ABC123" }

    it "returns true for a valid response" do
      api.connect_response_valid?(valid_response).should == true
    end

    it "returns false for an invalid response" do
      api.connect_response_valid?(invalid_response).should == false
    end

    it "returns false for non-found response" do
      api.connect_response_valid?(non_xml).should == false
    end
  end
end<commit_msg>Add hosts Spec for Api<commit_after>require 'spec_helper'

describe ManageEngine::AppManager::Api::Version11 do
  context "url response methods" do
    describe "connect_path" do
      it "returns the connect_path for AppManager" do
        FactoryGirl.build(:api, :version => "11").connect_path.should be_instance_of(String)
      end
    end

    describe "host_path" do
      it "returns the host_path for AppManager" do
        FactoryGirl.build(:api, :version => "11").host_path.should be_instance_of(String)
      end
    end
  end

  context "processing methods" do
    describe "connect_response_valid?" do
      let(:api)              { FactoryGirl.build :api, :version => "11" }
      let(:valid_response)   { File.open(File.dirname(__FILE__) + "/../../fixtures/valid_connect.xml", "r").read }
      let(:invalid_response) { File.open(File.dirname(__FILE__) + "/../../fixtures/invalid_connect.xml", "r").read }
      let(:non_xml)          { "ABC123" }

      it "returns true for a valid response" do
        api.connect_response_valid?(valid_response).should == true
      end

      it "returns false for an invalid response" do
        api.connect_response_valid?(invalid_response).should == false
      end

      it "returns false for non-found response" do
        api.connect_response_valid?(non_xml).should == false
      end
    end

    describe "hosts" do
      let(:api)       { FactoryGirl.build :api, :version => "11" }
      let(:all_hosts) { File.open(File.dirname(__FILE__) + "/../../fixtures/all_hosts.xml", "r").read }

      it "returns a hash of service arrays" do
        api.hosts(all_hosts).should == { "test-vm.local.host"  => [ "Service Monitoring", "Tomcat", "Tomcat", "JBoss", "PostgreSQL" ],
                                         "test2-vm.local.host" => [ "Service Monitoring", "Tomcat", "PostgreSQL" ] }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13142857142857142, 'fraction_numerical': 0.008403361344537815, 'mean_word_length': 3.005383580080754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1352633', 'n_tokens_mistral': 920, 'n_tokens_neox': 883, 'n_words': 213}