test/yao/resources/test_network.rb in yao-0.7.0 vs test/yao/resources/test_network.rb in yao-0.8.0
- old
+ new
@@ -1,6 +1,6 @@
-class TestNetwork < Test::Unit::TestCase
+class TestNetwork < TestYaoResource
def test_network
# https://docs.openstack.org/api-ref/network/v2/#networks
params = {
@@ -32,7 +32,34 @@
#map_attribute_to_attribute
assert_equal(network.physical_network, "physnet1")
assert_equal(network.type, "vlan")
assert_equal(network.segmentation_id, 1000)
+ 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'}
+ )
+
+ network = Yao::Network.new(
+ "project_id" => "0123456789abcdef0123456789abcdef",
+ "tenant_id" => "0123456789abcdef0123456789abcdef",
+ )
+
+ assert_instance_of(Yao::Tenant, network.tenant)
+ assert_instance_of(Yao::Tenant, network.project)
+ assert_equal(network.tenant.id, '0123456789abcdef0123456789abcdef')
+
+ assert_requested(stub)
end
end