test/yao/resources/test_router.rb in yao-0.7.0 vs test/yao/resources/test_router.rb in yao-0.8.0
- old
+ new
@@ -1,11 +1,7 @@
-class TestRouter < Test::Unit::TestCase
+class TestRouter < TestYaoResource
- def setup
- Yao.default_client.pool["network"] = Yao::Client.gen_client("https://example.com:12345")
- end
-
def test_router
# https://docs.openstack.org/api-ref/network/v2/?expanded=list-subnets-detail,list-routers-detail#list-routers
params = {
"admin_state_up" => true,
@@ -106,11 +102,11 @@
assert_equal(router.destination '')
assert_equal(router.nexthop '')
end
def test_iterfaces
- stub_request(:get, "https://example.com:12345/ports?device_id=00000000-0000-0000-0000-000000000000")
+ stub = stub_request(:get, "https://example.com:12345/ports?device_id=00000000-0000-0000-0000-000000000000")
.to_return(
status: 200,
body: <<-JSON,
{
"ports": [{
@@ -127,7 +123,31 @@
router = Yao::Router.new(params)
port = router.interfaces.first
assert_instance_of(Yao::Port, port)
assert_equal(port.id, "00000000-0000-0000-0000-000000000000")
+
+ assert_requested(stub)
+ end
+
+ def test_tenant
+
+ stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
+ .to_return(
+ status: 200,
+ body: <<-JSON,
+ {
+ "tenant": {
+ "id": "0123456789abcdef0123456789abcdef"
+ }
+ }
+ JSON
+ headers: {'Content-Type' => 'application/json'}
+ )
+
+ router = Yao::Router.new('tenant_id' => '0123456789abcdef0123456789abcdef')
+ assert_instance_of(Yao::Tenant, router.tenant)
+ assert_equal(router.tenant.id, '0123456789abcdef0123456789abcdef')
+
+ assert_requested(stub)
end
end