

class FakeResourceObject(object):
    '''Generate a fake SDK resource object based on given dictionary'''
    def __init__(self, params):
        for key in params:
            setattr(self, key, params[key])



class FakeResourceObject(object):
    '''Generate a fake SDK resource object based on given dictionary'''
    def __init__(self, params):
        for key in params:
            setattr(self, key, params[key])

    def to_dict(self):
        data = {
            'image': {
                'id': 'FAKE_IMAGE'
            },
            'flavor': {
                'id': 'FAKE_FLAVOR'
            },
            'addresses': {
                'private': [
                    {
                        'OS-EXT-IPS:type': 'fixed',
                        'addr': '10.0.0.5',
                        'version': 4
                    }
                ]
            },
            'security_groups': [
                {
                    'name': 'default'
                }
            ]
        }

        return data

Add to_dict() method for faked resource
Add to_dict() method for faked resource

When testing node_get with details, we expect the profile to return a
resource that has a to_dict() method. The existing faked resource
doesn't support this yet. This patch fixes it.

Change-Id: I52e0dad74a1140f8233280ff10a9c14ff1760f72

  
  
  class FakeResourceObject(object):
      '''Generate a fake SDK resource object based on given dictionary'''
      def __init__(self, params):
          for key in params:
              setattr(self, key, params[key])
  
+     def to_dict(self):
+         data = {
+             'image': {
+                 'id': 'FAKE_IMAGE'
+             },
+             'flavor': {
+                 'id': 'FAKE_FLAVOR'
+             },
+             'addresses': {
+                 'private': [
+                     {
+                         'OS-EXT-IPS:type': 'fixed',
+                         'addr': '10.0.0.5',
+                         'version': 4
+                     }
+                 ]
+             },
+             'security_groups': [
+                 {
+                     'name': 'default'
+                 }
+             ]
+         }
+ 
+         return data
+ 
Add to_dict() method for faked resource
## Code Before:


class FakeResourceObject(object):
    '''Generate a fake SDK resource object based on given dictionary'''
    def __init__(self, params):
        for key in params:
            setattr(self, key, params[key])

## Instruction:
Add to_dict() method for faked resource
## Code After:


class FakeResourceObject(object):
    '''Generate a fake SDK resource object based on given dictionary'''
    def __init__(self, params):
        for key in params:
            setattr(self, key, params[key])

    def to_dict(self):
        data = {
            'image': {
                'id': 'FAKE_IMAGE'
            },
            'flavor': {
                'id': 'FAKE_FLAVOR'
            },
            'addresses': {
                'private': [
                    {
                        'OS-EXT-IPS:type': 'fixed',
                        'addr': '10.0.0.5',
                        'version': 4
                    }
                ]
            },
            'security_groups': [
                {
                    'name': 'default'
                }
            ]
        }

        return data
