<commit_before>require "prtg/client"
require  File.dirname(__FILE__) + "/helpers/client_helper_methods.rb"


describe Prtg::Client, "getpasshash" do

  include ClientHelperMethods

  it "request the hash via the given host" do
    expected_url = "/api/getpasshash.htm?username=foo&password=<PASSWORD>"
    client = create_client
    client.host.should_receive(:get).with(expected_url).and_return(create_response("111111"))
    client.getpasshash
  end
end

describe Prtg::Client, "initialize" do

  include ClientHelperMethods

  it "raises an ArgumentError if no host is given" do
    lambda{ Prtg::Client.new() }.should raise_error(ArgumentError)
  end
end

describe Prtg::Client, "passhash" do

  include ClientHelperMethods

  it "uses the getpasshash method" do
    client = create_client
    client.should_receive(:getpasshash).and_return("1111111")
    client.passhash.should eq("<PASSWORD>")
  end
end

describe Prtg::Client, "live_data" do

  include ClientHelperMethods

  it "instance a Prtg::Query" do
    client = create_client
    Prtg::Query.should_receive(:new).with(client).and_return(true)
    client.live_data
  end
end

# describe Prtg::Client, "devices" do
#
#   include ClientHelperMethods
#
#   it "should return an hash" do
#     client = create_client
#     client.host.should_receive(:get).and_return(create_response(<<-XML))
# <?xml version="1.0" encoding="UTF-8" ?>
#   <devices>
#    <prtg-version>8.4.2.2321</prtg-version>
#    <item>
#     <objid>2002</objid>
#     <probe>prtgx (Strato)</probe>
#     <group>Windows</group>
#     <device>Homepage Calls</device>
#     <host>127.0.0.1</host>
#     <downsens_raw>0000000001</downsens_raw>
#     <partialdownsens_raw>0000000000</partialdownsens_raw>
#     <downacksens_raw>0000000000</downacksens_raw>
#     <upsens_raw>0000000033</upsens_raw>
#     <warnsens_raw>0000000000</warnsens_raw>
#     <pausedsens_raw>0000000002</pausedsens_raw>
#     <unusualsens_raw>0000000000</unusualsens_raw>
#     <undefinedsens_raw>0000000000</undefinedsens_raw>
#    </item>
#    <item>
#     <objid>2057</objid>
#     <probe>prtgx (Strato)</probe>
#     <group>Windows</group>
#     <device>SSL Expiry Checks</device>
#     <host>127.0.0.1</host>
#     <downsens_raw>0000000000</downsens_raw>
#     <partialdownsens_raw>0000000000</partialdownsens_raw>
#     <downacksens_raw>0000000000</downacksens_raw>
#     <upsens_raw>0000000016</upsens_raw>
#     <warnsens_raw>0000000001</warnsens_raw>
#     <pausedsens_raw>0000000001</pausedsens_raw>
#     <unusualsens_raw>0000000001</unusualsens_raw>
#     <undefinedsens_raw>0000000000</undefinedsens_raw>
#    </item>
# </devices>
#     XML
#     client.devices.should be_a(Hash)
#   end
# end
<commit_msg>Fix getpasshash test<commit_after>require "prtg/client"
require  File.dirname(__FILE__) + "/helpers/client_helper_methods.rb"


describe Prtg::Client, "getpasshash" do

  include ClientHelperMethods

  it "request the hash via the given host" do

    expected_params = ["/api/getpasshash.htm?username=foo&password=<PASSWORD>",
                       {"accept-encoding"=>"gzip"}]

    client = create_client
    client.host.should_receive(:get).with(*expected_params).
                and_return(create_response("111111"))
    client.getpasshash
  end
end

describe Prtg::Client, "initialize" do

  include ClientHelperMethods

  it "raises an ArgumentError if no host is given" do
    lambda{ Prtg::Client.new() }.should raise_error(ArgumentError)
  end
end

describe Prtg::Client, "passhash" do

  include ClientHelperMethods

  it "uses the getpasshash method" do
    client = create_client
    client.should_receive(:getpasshash).and_return("<PASSWORD>")
    client.passhash.should eq("<PASSWORD>")
  end
end

describe Prtg::Client, "live_data" do

  include ClientHelperMethods

  it "instance a Prtg::Query" do
    client = create_client
    Prtg::Query.should_receive(:new).with(client).and_return(true)
    client.live_data
  end
end

# describe Prtg::Client, "devices" do
#
#   include ClientHelperMethods
#
#   it "should return an hash" do
#     client = create_client
#     client.host.should_receive(:get).and_return(create_response(<<-XML))
# <?xml version="1.0" encoding="UTF-8" ?>
#   <devices>
#    <prtg-version>8.4.2.2321</prtg-version>
#    <item>
#     <objid>2002</objid>
#     <probe>prtgx (Strato)</probe>
#     <group>Windows</group>
#     <device>Homepage Calls</device>
#     <host>127.0.0.1</host>
#     <downsens_raw>0000000001</downsens_raw>
#     <partialdownsens_raw>0000000000</partialdownsens_raw>
#     <downacksens_raw>0000000000</downacksens_raw>
#     <upsens_raw>0000000033</upsens_raw>
#     <warnsens_raw>0000000000</warnsens_raw>
#     <pausedsens_raw>0000000002</pausedsens_raw>
#     <unusualsens_raw>0000000000</unusualsens_raw>
#     <undefinedsens_raw>0000000000</undefinedsens_raw>
#    </item>
#    <item>
#     <objid>2057</objid>
#     <probe>prtgx (Strato)</probe>
#     <group>Windows</group>
#     <device>SSL Expiry Checks</device>
#     <host>127.0.0.1</host>
#     <downsens_raw>0000000000</downsens_raw>
#     <partialdownsens_raw>0000000000</partialdownsens_raw>
#     <downacksens_raw>0000000000</downacksens_raw>
#     <upsens_raw>0000000016</upsens_raw>
#     <warnsens_raw>0000000001</warnsens_raw>
#     <pausedsens_raw>0000000001</pausedsens_raw>
#     <unusualsens_raw>0000000001</unusualsens_raw>
#     <undefinedsens_raw>0000000000</undefinedsens_raw>
#    </item>
# </devices>
#     XML
#     client.devices.should be_a(Hash)
#   end
# end

{'fraction_non_alphanumeric': 0.13409337676438654, 'fraction_numerical': 0.0722041259500543, 'mean_word_length': 4.309317963496638, 'pattern_counts': {'":': 0, '<': 134, '<?xml version=': 2, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 6, 'substrings_counts': 33, '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': '5406220', 'n_tokens_mistral': 2286, 'n_tokens_neox': 1935, 'n_words': 298}