HYD-4821 Test for allow rest interface to expand selective related fields.
HYD-4821 Test for allow rest interface to expand selective related fields.

At present the decision as to whether a related field is expanded
is hard coded in the tastypie (this is the tastypie way). We need
a way for the front end to be able to expand / not-expand at will any field.

Example.

the network_interface contains nids (when expanded they look like this)
{
  ...
  nids: {
    full nid1 detail
  }
  ..
}
or
{
  ...
  nids: "/api/nid/1"
  ..
}

We need a field in the request that switches it so we will add

dehydrate__{object}={True/False}

object can be nid, not lnet_configuration etc.

This then overrides the configured value.

The solution is to replace dehydrate_related in the tastypie RelatedField
class with a version that inspects for the dehydrate__{object} variable and
then overides the default value applicably. One corner case is that because
(for example) a nid contains a reference to a host and a host contains a
reference to a nid. dehydrate_nid and dehydrate_host would cause infinite
recursion. For this reason the args are stripped but preserved as the stack
of objects is dehydrated.

This patch is the unit tests for the change, integration tests happen as part
of all the other tests as this code is called for every api call.

 - Addition of test_related_field.py which carries out all the unit test.

Change-Id: I95440250a3369bbcc56fde8006e6f0a7806c68b9
Signed-off-by: Chris Gearing <149a3c4298d99c315fc555357d57d2940923ba5f@intel.com>
Reviewed-on: http://review.whamcloud.com/16768
Tested-by: Jenkins
Tested-by: Chroma Test User <a0b98b2ff5154776fa24760ef410655af7a8b56c@intel.com>
Reviewed-by: Tom Nabarro <27c585386b86ec0acfeeb448326cb9c60162db51@intel.com>
Reviewed-by: Joe Grund <5a0004131f5af71cc30270f318d2c30ba7aaa99a@intel.com>

intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre