Discussion:
Populating Mock self.data
Dave Johnston
2016-04-25 13:22:03 UTC
Permalink
Hi,

I've been trying to write some tests for code that uses the
Fog::Orchestration::Openstack class.

I call a request method called 'list_resources'. The Mock for this request
looks like this:
class Mock
def list_resources(options = {}, options_deprecated = {})
resources = self.data[:resources].values

Excon::Response.new(
:body => { 'resources' => resources },
:status => 200
)
end
end


The tests fail because self.data[:resources] is nil. Does the Fog mock
framework provide a mechanism to populate the 'data' hash prior to
executing the test?
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
geemus (Wesley Beary)
2016-04-25 14:06:52 UTC
Permalink
I haven't used the openstack side of things in particular much, but the
general pattern in fog is to use the create methods to populate the mocks.
So if you have mock on and create some resources, then call list_resources,
they should be included. Hope that helps, but if not somebody with more
specific knowledge around this may be able to chime in.
Post by Dave Johnston
Hi,
I've been trying to write some tests for code that uses the
Fog::Orchestration::Openstack class.
I call a request method called 'list_resources'. The Mock for this
class Mock
def list_resources(options = {}, options_deprecated = {})
resources = self.data[:resources].values
Excon::Response.new(
:body => { 'resources' => resources },
:status => 200
)
end
end
The tests fail because self.data[:resources] is nil. Does the Fog mock
framework provide a mechanism to populate the 'data' hash prior to
executing the test?
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...