File: quota_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 (56 lines) | stat: -rw-r--r-- 1,661 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
require 'test_helper'

describe "Fog::OpenStack::Network | quota requests" do
  before do
    identity = Fog::OpenStack::Identity.new(:openstack_identity_api_version => 'v2.0')
    @tenant_id = identity.list_tenants.body['tenants'].first['id']
    @quota_format = {
      'subnet'     => Fog::Nullable::Integer,
      'router'     => Fog::Nullable::Integer,
      'port'       => Fog::Nullable::Integer,
      'network'    => Fog::Nullable::Integer,
      'floatingip' => Fog::Nullable::Integer
    }

    @quotas_format = [
      {
        'subnet'     => Fog::Nullable::Integer,
        'router'     => Fog::Nullable::Integer,
        'port'       => Fog::Nullable::Integer,
        'network'    => Fog::Nullable::Integer,
        'floatingip' => Fog::Nullable::Integer,
        'tenant_id'  => Fog::Nullable::String
      }
    ]

    @quota = network.get_quota(@tenant_id).body['quota']
  end

  describe "success" do
    it "#get_quotas" do
      network.get_quotas.body.must_match_schema('quotas' => @quotas_format)
    end

    it "#get_quota" do
      @quota.must_match_schema(@quota_format)
    end

    it "#update_quota" do
      new_values = @quota.merge(
        'volumes'   => @quota['subnet'] / 2,
        'snapshots' => @quota['router'] / 2
      )

      network.update_quota(@tenant_id, new_values.clone)
      network.get_quota(@tenant_id).body['quota'].must_equal new_values
      network.update_quota(@tenant_id, @quota.clone)
      network.get_quota(@tenant_id).body['quota'].must_equal @quota
    end
  end

  describe "#delete_quota" do
    it "succeeds" do
      network.delete_quota(@tenant_id).status.must_equal 204
    end
  end
end