Sha256: c2ece798f3c170844fa34a3ba8320ba2ed49c0d03d80e27b4c08070bcb648e23

Contents?: true

Size: 1.96 KB

Versions: 22

Compression:

Stored size: 1.96 KB

Contents

class TestResource < TestYaoResource

  def test_resource

    # https://docs.openstack.org/ceilometer/pike/webapi/v2.html#Resource
    params = {
      "links" =>[
        {
          "href" => "http://localhost:8777/v2/resources/bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
          "rel" => "self"
        },
        {
          "href" => "http://localhost:8777/v2/meters/volume?q.field=resource_id&q.value=bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
          "rel" => "volume"
        }
      ],
      "metadata" => {
        "name1" =>"value1",
        "name2" =>"value2"
      },
      "project_id" => "35b17138-b364-4e6a-a131-8f3099c5be68",
      "resource_id" => "bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
      "source" => "openstack",
      "user_id" => "efd87807-12d2-4b38-9c70-5f5c2ac427ff",
      # uncodumented
      "last_sample_timestamp" => "2019-08-29T08:41:22.555000",
      "first_sample_timestamp" => "2019-03-19T08:41:21.383000",
    }

    resource = Yao::Resources::Resource.new(params)

    assert_equal("2019-08-29T08:41:22.555000", resource.last_sample_timestamp)
    assert_equal(Time.parse("2019-08-29T08:41:22.555000"), resource.last_sampled_at)

    assert_equal("2019-03-19T08:41:21.383000", resource.first_sample_timestamp)
    assert_equal(Time.parse("2019-03-19T08:41:21.383000"), resource.first_sampled_at)

    assert_equal("bd9431c1-8d69-4ad3-803a-8d4a6b89fd36", resource.id)
    assert_equal("bd9431c1-8d69-4ad3-803a-8d4a6b89fd36", resource.resource_id)
    assert_equal("efd87807-12d2-4b38-9c70-5f5c2ac427ff", resource.user_id)
    assert_equal({
      "name1" =>"value1",
      "name2" =>"value2"
    }, resource.metadata)
    assert_equal([
      {
        "href" => "http://localhost:8777/v2/resources/bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
        "rel" => "self"
      },
      {
        "href" => "http://localhost:8777/v2/meters/volume?q.field=resource_id&q.value=bd9431c1-8d69-4ad3-803a-8d4a6b89fd36",
        "rel" => "volume"
      }
    ], resource.links)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
yao-0.21.0 test/yao/resources/test_resource.rb
yao-0.20.0 test/yao/resources/test_resource.rb
yao-0.19.0 test/yao/resources/test_resource.rb
yao-0.18.0 test/yao/resources/test_resource.rb
yao-0.17.0 test/yao/resources/test_resource.rb
yao-0.16.0 test/yao/resources/test_resource.rb
yao-0.15.0 test/yao/resources/test_resource.rb
yao-0.14.0 test/yao/resources/test_resource.rb
yao-0.13.4 test/yao/resources/test_resource.rb
yao-0.13.3 test/yao/resources/test_resource.rb
yao-0.13.2 test/yao/resources/test_resource.rb
yao-0.13.1 test/yao/resources/test_resource.rb
yao-0.13.0 test/yao/resources/test_resource.rb
yao-0.12.0 test/yao/resources/test_resource.rb
yao-0.11.3 test/yao/resources/test_resource.rb
yao-0.11.2 test/yao/resources/test_resource.rb
yao-0.11.1 test/yao/resources/test_resource.rb
yao-0.11.0 test/yao/resources/test_resource.rb
yao-0.10.1 test/yao/resources/test_resource.rb
yao-0.10.0 test/yao/resources/test_resource.rb