test/yao/resources/test_floating_ip.rb in yao-0.7.0 vs test/yao/resources/test_floating_ip.rb in yao-0.8.0
- old
+ new
@@ -1,13 +1,7 @@
-class TestFloatingIP < Test::Unit::TestCase
+class TestFloatingIP < TestYaoResource
- def setup
- Yao.default_client.admin_pool["identity"] = Yao::Client.gen_client("https://example.com:12345")
- Yao.default_client.pool["network"] = Yao::Client.gen_client("https://example.com:12345")
- Yao.default_client.pool["compute"] = Yao::Client.gen_client("https://example.com:12345")
- end
-
def test_floating_ip
params = {
"router_id" => "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
"description" => "for test",
"dns_domain" => "my-domain.org.",
@@ -65,37 +59,41 @@
assert_equal(fip.port_forwardings, [])
end
def test_floating_ip_to_router
- stub_request(:get, "https://example.com:12345/routers/00000000-0000-0000-0000-000000000000")
+ stub = stub_request(:get, "https://example.com:12345/routers/00000000-0000-0000-0000-000000000000")
.to_return(
status: 200,
body: <<-JSON,
{
- "routers": [{
- "id": "0123456789abcdef0123456789abcdef"
- }]
+ "router": {
+ "id": "00000000-0000-0000-0000-000000000000"
+ }
}
JSON
headers: {'Content-Type' => 'application/json'}
)
fip = Yao::FloatingIP.new("router_id" => "00000000-0000-0000-0000-000000000000")
+
assert_instance_of(Yao::Router, fip.router)
+ assert_equal(fip.router.id, "00000000-0000-0000-0000-000000000000")
+
+ assert_requested(stub)
end
- def test_floating_to_tenant
+ def test_tenant
- stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
+ stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
.to_return(
status: 200,
body: <<-JSON,
{
- "tenants": [{
+ "tenant": {
"id": "0123456789abcdef0123456789abcdef"
- }]
+ }
}
JSON
headers: {'Content-Type' => 'application/json'}
)
@@ -104,26 +102,33 @@
"tenant_id" => "0123456789abcdef0123456789abcdef",
)
assert_instance_of(Yao::Tenant, fip.tenant)
assert_instance_of(Yao::Tenant, fip.project)
+ assert_equal(fip.tenant.id, '0123456789abcdef0123456789abcdef')
+
+ assert_requested(stub)
end
def test_floating_ip_to_port
- stub_request(:get, "https://example.com:12345/ports/00000000-0000-0000-0000-000000000000")
+ stub = stub_request(:get, "https://example.com:12345/ports/00000000-0000-0000-0000-000000000000")
.to_return(
status: 200,
body: <<-JSON,
{
- "ports": [{
- "id": "0123456789abcdef0123456789abcdef"
- }]
+ "port": {
+ "id": "00000000-0000-0000-0000-000000000000"
+ }
}
JSON
headers: {'Content-Type' => 'application/json'}
)
fip = Yao::FloatingIP.new("port_id" => "00000000-0000-0000-0000-000000000000")
+
assert_instance_of(Yao::Port, fip.port)
+ assert_equal(fip.port.id, "00000000-0000-0000-0000-000000000000")
+
+ assert_requested(stub)
end
end