test/yao/resources/test_flavor.rb in yao-0.7.0 vs test/yao/resources/test_flavor.rb in yao-0.8.0

- old
+ new

@@ -1,11 +1,7 @@ -class TestFlavor < Test::Unit::TestCase +class TestFlavor < TestYaoResource - def setup - Yao.default_client.pool["compute"] = Yao::Client.gen_client("https://example.com:12345") - end - def test_flavor # https://docs.openstack.org/api-ref/compute/?expanded=list-flavors-detail,list-flavors-with-details-detail#list-flavors-with-details params = { "OS-FLV-DISABLED:disabled" => false, "disk" => 1, @@ -48,12 +44,12 @@ assert_equal(flavor.ram('M'), 512) assert_equal(flavor.ram('G'), 0.5) assert_equal(flavor.memory, 512) end - def test_list_detail - stub_request(:get, "https://example.com:12345/flavors/detail"). + def test_list + stub = stub_request(:get, "https://example.com:12345/flavors/detail"). to_return( status: 200, body: <<-JSON, { "flavors": [ @@ -85,10 +81,20 @@ } JSON headers: {'Content-Type' => 'application/json'} ) - flavors = Yao::Flavor.list_detail - assert { flavors.first.instance_of? Yao::Flavor } + assert(Yao::Flavor.resources_detail_available) + + flavors = Yao::Flavor.list + assert_instance_of(Yao::Flavor, flavors.first) assert_equal(flavors.first.name, "m1.tiny") + + assert_requested(stub) + end + + def test_list_detail + # Yao::Flavor.list_detail と Yao::Flavor.list が alias にあることをテストする + # see also: https://stackoverflow.com/questions/25883618/how-to-test-method-alias-ruby + assert_equal(Yao::Flavor.method(:list_detail), Yao::Flavor.method(:list)) end end