コード例 #1
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=FollowerRelationship,
             version="v1",
         ),
         follower_relationship_id=obj.id,
     )
     links["user"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.user_id,
     )
     links["follower"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.follower_id,
     )
     return links.to_dict()
コード例 #2
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Person),
         person_id=obj.id,
     )
     return links.to_dict()
コード例 #3
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Address),
         address_id=obj.id,
     )
     return links.to_dict()
コード例 #4
0
    def get_links(self, obj):
        links = Links()
        links["self"] = Link.for_(
            Operation.Retrieve,
            Namespace(subject=OrderEvent, version="v1",),
            order_event_id=obj.id,
        )

        return links.to_dict()
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Example,
             version="v1",
         ),
         example_id=obj.id,
     )
     return links.to_dict()
コード例 #6
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Topping, version="v1",),
         topping_id=obj.id,
     )
     links["parent:pizza"] = Link.for_(
         Operation.Search, Namespace(subject=Pizza, version="v1"), id=obj.pizza_id
     )
     return links.to_dict()
コード例 #7
0
ファイル: fixtures.py プロジェクト: srikalyan/microcosm-flask
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         ns=Namespace(
             subject=Address,
             path=Namespace(subject=Person, ).instance_path,
         ),
         person_id=obj.person_id,
         address_id=obj.id,
     )
     return links.to_dict()
コード例 #8
0
def test_links_init_list():
    links = Links(foo=[
        Link("bar"),
        Link("baz"),
    ])
    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": [{
                "href": "bar",
            }, {
                "href": "baz",
            }],
        })))
コード例 #9
0
def test_links_as_item():
    links = Links()
    links["foo"] = Link("foo")
    links["bar"] = Link("bar")

    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": {
                "href": "foo",
            },
            "bar": {
                "href": "bar",
            },
        })))
コード例 #10
0
def test_links_init():
    links = Links(
        foo=Link("foo"),
        bar=Link("bar"),
    )
    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": {
                "href": "foo",
            },
            "bar": {
                "href": "bar",
            },
        })))
コード例 #11
0
ファイル: user_resources.py プロジェクト: sindyjlee/rest-api
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.id,
     )
     links["tweets"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="tweets",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["followers"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="followers",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["following"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="following",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["feed"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="feed",
             version="v1",
         ),
         user_id=obj.id,
     )
     return links.to_dict()
コード例 #12
0
ファイル: order_resources.py プロジェクト: pankajghosh/peetza
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Order,
             version="v1",
         ),
         order_id=obj.id,
     )
     # links["child:pizza"] = Link.for_(
     #     Operation.Retrieve,
     #     Namespace(
     #         subject=Pizza,
     #         version="v1",
     #     ),
     #     pizza_id=obj.pizza_id,
     # )
     return links.to_dict()
コード例 #13
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Tweet,
             version="v1",
         ),
         tweet_id=obj.id,
     )
     links["user"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.user_id,
     )
     return links.to_dict()
コード例 #14
0
def test_links_empty():
    links = Links()
    assert_that(links.to_dict(), is_(equal_to({})))
コード例 #15
0
ファイル: fixtures.py プロジェクト: srikalyan/microcosm-flask
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(Operation.Retrieve, Person, person_id=obj.id)
     return links.to_dict()