def test_resource3(self):
     a = Resource("/foo", {'key1': 'value1', 'key2': 'value2'})
     b = Resource("/bar", {'key3': 'value3', 'key4': 'value4'})
     a.add_embedded_resource("bars", b)
     tmp = a.to_dict()
     self.assertEqual(tmp["_embedded"]['bars'][0]['key3'], 'value3')
     self.assertEqual(tmp["_embedded"]['bars'][0]['key4'], 'value4')
 def get(self):
     '''
     @summary: deals with GET request (getting a JSON HAL of resources)
     '''
     resources = Resource(self.reverse_url("resources"))
     resources_names = LOCK_MANAGER_INSTANCE.get_resources_names()
     for resource_name in resources_names:
         tmp = LOCK_MANAGER_INSTANCE.get_resource_as_dict(resource_name)
         resource = Resource(self.reverse_url("resource", tmp['name']), {"name": tmp['name']})
         resources.add_embedded_resource("resources", resource)
     self.set_header("Content-Type", "application/hal+json")
     self.finish(resources.to_json())
 def get(self, name):
     '''
     @summary: deals with GET request (getting a JSON HAL of the resource)
     @param name: name of the resource
     '''
     tmp = LOCK_MANAGER_INSTANCE.get_resource_as_dict(name)
     resource = Resource(self.reverse_url("resource", name), {"name": name})
     if tmp:
         for lock_dict in tmp['locks']:
             lock = Resource(self.reverse_url("lock", name, lock_dict['uid']), lock_dict)
             resource.add_embedded_resource("locks", lock)
     self.set_header("Content-Type", "application/hal+json")
     self.finish(resource.to_json())
 def get(self, name):
     '''
     @summary: deals with GET request (getting a JSON HAL of the resource)
     @param name: name of the resource
     '''
     tmp = LOCK_MANAGER_INSTANCE.get_resource_as_dict(name)
     resource = Resource(self.reverse_url("resource", name), {"name": name})
     if tmp:
         for lock_dict in tmp['locks']:
             lock = Resource(
                 self.reverse_url("lock", name, lock_dict['uid']),
                 lock_dict)
             resource.add_embedded_resource("locks", lock)
     self.set_header("Content-Type", "application/hal+json")
     self.finish(resource.to_json())