コード例 #1
0
ファイル: tests.py プロジェクト: vituocgia/boxme-api
    def test_reverse_one_to_one_post(self):
        ed = ExtraData.objects.create(name='ed_name')
        resource = TagResource()

        # Post the extradata element which is attached to a "reverse" OneToOne
        request = MockRequest()
        request.method = "POST"
        request.body = json.dumps({
            "name": "tag_name",
            "tagged": [],
            "extradata": "/v1/extradata/%s/" % ed.pk
        })

        resp = resource.post_list(request)
        # Assert that the status code is CREATED
        self.assertEqual(resp.status_code, 201)

        tag = Tag.objects.get(pk=int(resp['Location'].split("/")[-2]))
        self.assertEqual(tag.extradata, ed)
コード例 #2
0
ファイル: tests.py プロジェクト: beedesk/django-tastypie
    def test_reverse_one_to_one_post(self):
        ed = ExtraData.objects.create(name='ed_name')
        resource = TagResource()

        # Post the extradata element which is attached to a "reverse" OneToOne
        request = MockRequest()
        request.method = "POST"
        request.body = json.dumps({
            "name": "tag_name",
            "tagged": [],
            "extradata": "/v1/extradata/%s/" % ed.pk
        })

        resp = resource.post_list(request)
        # Assert that the status code is CREATED
        self.assertEqual(resp.status_code, 201)

        tag = Tag.objects.get(pk=int(resp['Location'].split("/")[-2]))
        self.assertEqual(tag.extradata, ed)
コード例 #3
0
ファイル: tests.py プロジェクト: vituocgia/boxme-api
    def test_one_to_one_two_patches_in_a_row(self):
        resource = TagResource()
        ed = ExtraData.objects.create(name='ed_name')
        tag = Tag.objects.create(name='tag_name')
        tag2 = Tag.objects.create(name="tag_name2")
        extra_data = "/v1/extradata/%s/" % ed.pk

        self.patch_details(resource, tag.pk, extradata=extra_data)
        resp = self.patch_details(resource, tag2.pk, name="new_tag_name")

        self.assertEqual(resp.status_code, 202)
        self.assertEqual(Tag.objects.get(pk=tag2.pk).name, "new_tag_name")
コード例 #4
0
from related_resource.api.resources import NoteResource, UserResource,\
    CategoryResource, TagResource, TaggableTagResource, TaggableResource,\
    ExtraDataResource, FreshNoteResource, FreshMediaBitResource,\
    ForumResource, CompanyResource, ProductResource, AddressResource,\
    PersonResource, DogResource, DogHouseResource, BoneResource,\
    LabelResource, PostResource, OrderResource, OrderItemResource,\
    NoteWithUpdatableUserResource, ContactResource, ContactGroupResource


api = Api(api_name='v1')
api.register(NoteResource(), canonical=True)
api.register(NoteWithUpdatableUserResource(), canonical=True)
api.register(UserResource(), canonical=True)
api.register(CategoryResource(), canonical=True)
api.register(TagResource(), canonical=True)
api.register(TaggableResource(), canonical=True)
api.register(TaggableTagResource(), canonical=True)
api.register(ExtraDataResource(), canonical=True)
api.register(FreshNoteResource(), canonical=True)
api.register(FreshMediaBitResource(), canonical=True)
api.register(ForumResource(), canonical=True)
api.register(CompanyResource(), canonical=True)
api.register(ProductResource(), canonical=True)
api.register(AddressResource(), canonical=True)
api.register(PersonResource(), canonical=True)
api.register(DogResource(), canonical=True)
api.register(DogHouseResource(), canonical=True)
api.register(BoneResource(), canonical=True)
api.register(PostResource(), canonical=True)
api.register(LabelResource(), canonical=True)