ACK
On 11/08/12 04:03, [email protected] wrote:
> A little more of the simple CIMI tests - as one can see from 5/6 and 6/6,
> the fact that responses can be either XML or JSON will led to a huge amount
> of (mindnumbing) duplication in the tests. We need some way to run the same
> tests over both the XML and the JSON.
We have the same problem for the deltacloud API tests - right now
they're exercising mainly the xml responses with very little checking of
json. For CIMI the situation is exacerbated by the fact that message
bodies themselves are xml/json rather than just passing of parameters.
For those tests that deal with parsing of responses, immediate thought
is combination of randomly choosing xml/json and then using common code
up to the point where the response needs to be parsed:
before :each do
format = [:xml, :json].choice
res = cep(:accept => format)
end
it "should use CloudEntryPoint as the #{format} root" do
res.send(:send, format.to_s).root.name.must_equal "CloudEntryPoint"
case format
when :xml
names = res.xml.xpath("/c:CloudEntryPoint", api.ns).map { |e|
e.name }
when :json
names = ...
end
names.must_equal ["CloudEntryPoint"]
end
#not the best example above but in general:
it #some test do
res = common_request_code(:accept=> format)
case format
when ...
end
If we come up with a fancy dsl to abstract the differences between
parsing the xml or parsing the json this might be simplified further but
not sure if it's a) possible and b) worth the overhead to get rid of the
case statements...?
marios
>
> David
>