def as_link(self): """Returns a ``Link`` to the document. This method is used when adding a link to a ``Builder`` from a ``dougrain.Document``. """ return link.Link(self.o['_links']['self'], None)
def testASingleLinkCanBeIterated(self): the_link = link.Link({"href": "/"}, "http://localhost/") count = 0 for a_link in the_link: count += 1 self.assertEquals(the_link, a_link) self.assertEquals(1, count)
def setUp(self): self.link = link.Link( { 'href': "/foo", 'name': "bar", 'title': "Bar", 'type': "application/hal+json", 'profile': "/profiles/foo", 'hreflang': "en", 'deprecation': "/deprecation/foo" }, "http://localhost/")
def link(self, href, **kwargs): """Retuns a new link relative to this resource.""" return link.Link(dict(href=href, **kwargs), self.base_uri)
def setUp(self): self.link = link.Link({'href': "/foo/{arg1}"}, "http://localhost/")
def setUp(self): self.link = link.Link({'href': "http://localhost/"}, None)
def setUp(self): self.link = link.Link({ 'href': "/foo/{arg1}", 'templated': True }, "http://localhost/")
def assertVariables(self, variables, href): if isinstance(variables, str): variables = variables.split() lnk = link.Link({'href': href, 'templated': True}, "http://localhost/") self.assertEquals(variables, lnk.variables)
def setUp(self): self.curies = curie.CurieCollection() tlink = lambda url: link.Link(dict(href=url, templated=True), "http://localhost/api/products/1") self.curies['role'] = tlink("http://localhost/roles/{rel}") self.curies['spec'] = tlink("/specifications/{rel}")