File: meter_tests.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (58 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "test_helper"

describe "Fog::OpenStack::Metering | meter requests" do
  before do
    @metering = Fog::OpenStack::Metering.new

    @sample_format = {
      'counter_name'      => String,
      'user_id'           => String,
      'resource_id'       => String,
      'timestamp'         => String,
      'resource_metadata' => Hash,
      'source'            => String,
      'counter_unit'      => String,
      'counter_volume'    => Float,
      'project_id'        => String,
      'message_id'        => String,
      'counter_type'      => String
    }

    @meter_format = {
      'user_id'     => String,
      'name'        => String,
      'resource_id' => String,
      'project_id'  => String,
      'type'        => String,
      'unit'        => String
    }

    @statistics_format = {
      'count'          => Integer,
      'duration_start' => String,
      'min'            => Float,
      'max'            => Float,
      'duration_end'   => String,
      'period'         => Integer,
      'period_end'     => String,
      'duration'       => Float,
      'period_start'   => String,
      'avg'            => Float,
      'sum'            => Float
    }
  end

  describe "success" do
    it "#list_meters" do
      @metering.list_meters.body.must_match_schema([@meter_format])
    end

    it "#get_samples" do
      @metering.get_samples('test').body.must_match_schema([@sample_format])
    end

    it "#get_statistics" do
      @metering.get_statistics('test').body.must_match_schema([@statistics_format])
    end
  end
end