Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
 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/")
Beispiel #4
0
 def link(self, href, **kwargs):
     """Retuns a new link relative to this resource."""
     return link.Link(dict(href=href, **kwargs), self.base_uri)
Beispiel #5
0
 def setUp(self):
     self.link = link.Link({'href': "/foo/{arg1}"}, "http://localhost/")
Beispiel #6
0
 def setUp(self):
     self.link = link.Link({'href': "http://localhost/"}, None)
Beispiel #7
0
 def setUp(self):
     self.link = link.Link({
         'href': "/foo/{arg1}",
         'templated': True
     }, "http://localhost/")
Beispiel #8
0
    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)
Beispiel #9
0
 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}")