<commit_before>require File.join(File.dirname(__FILE__), 'helper')
require 'pp'

class SfccCimcClient < SfccTestCase
    
  context "a running CIMOM with no auth" do

    setup do
      setup_cim_client
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
    end
    
    should "be running" do
      assert cimom_running?
    end
    
    should "be of class Client" do
      assert_kind_of(Sfcc::Cim::Client, @client)
    end
    
    should "allow for query" do
      result = @client.query(@op, "select * from CIM_OperatingSystem", "wql")
      result.each do |instance|
        puts "query result: #{instance}"
      end
    end
    
    should "be able to get set properties using an object path" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      # @client.instance_names(@op).each do |path|
      @client.query(@op, "select * from Linux_OperatingSystem", "wql").each do |instance|
#        assert ! @client.property(instance.object_path, "PrimaryOwnerContact").empty?        
      end
    end

    should "be able to get an instance from the object path" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
      instance2 = @client.get_instance(instance.object_path)
      assert_kind_of Sfcc::Cim::Instance, instance2
    end

    should "be able to create an instance" do
      op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      instance = Sfcc::Cim::Instance.new(op)
      assert_raise Sfcc::Cim::ErrorNotSupported do
        new_op = @client.create_instance(op, instance)
      end<commit_msg>add test for invalid class<commit_after>require File.join(File.dirname(__FILE__), 'helper')
require 'pp'

class SfccCimcClient < SfccTestCase
    
  context "a running CIMOM with no auth" do

    setup do
      setup_cim_client
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
    end
    
    should "be running" do
      assert cimom_running?
    end
    
    should "be of class Client" do
      assert_kind_of(Sfcc::Cim::Client, @client)
    end
    
    should "allow for query" do
      result = @client.query(@op, "select * from CIM_OperatingSystem", "wql")
      result.each do |instance|
        puts "query result: #{instance}"
      end
    end
    
    should "be able to get set properties using an object path" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      # @client.instance_names(@op).each do |path|
      @client.query(@op, "select * from Linux_OperatingSystem", "wql").each do |instance|
#        assert ! @client.property(instance.object_path, "PrimaryOwnerContact").empty?        
      end
    end

    should "be able to get a class from the object path" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      cimclass = @client.get_class(@op)
      assert_kind_of Sfcc::Cim::Class, cimclass
    end

    should "report error when getting invalid class" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "NotExistingClass")
      assert_raise Sfcc::Cim::ErrorNotFound do
        cimclass = @client.get_class(@op)
      end
    end
    
    should "be able to get an instance from the object path" do
      @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
      instance2 = @client.get_instance(instance.object_path)
      assert_kind_of Sfcc::Cim::Instance, instance2
    end

    should "be able to create an instance" do
      op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
      instance = Sfcc::Cim::Instance.new(op)
      assert_raise Sfcc::Cim::ErrorNotSupported do
        new_op = @client.create_instance(op, instance)
      end
{'fraction_non_alphanumeric': 0.11702402479979333, 'fraction_numerical': 0.003616636528028933, 'mean_word_length': 3.163440860215054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7364237', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1276, 'n_words': 312}