Ejemplo n.º 1
0
    def test_same_object_added(self):
        """
        From Issue #1035
        """

        user = User.objects.create(username="******")

        ur = UserResource()
        fr = ForumResource()

        resp = self.client.post(
            fr.get_resource_uri(),
            content_type="application/json",
            data=json.dumps(
                {
                    "name": "Test Forum",
                    "members": [ur.get_resource_uri(user)],
                    "moderators": [ur.get_resource_uri(user)],
                }
            ),
        )
        self.assertEqual(resp.status_code, 201, resp.content)
        data = json.loads(resp.content.decode("utf-8"))
        self.assertEqual(len(data["moderators"]), 1)
        self.assertEqual(len(data["members"]), 1)
Ejemplo n.º 2
0
    def test_same_object_added(self):
        """
        From Issue #1035
        """
        user = User.objects.create(username='******')

        ur = UserResource()
        fr = ForumResource()

        resp = self.client.post(fr.get_resource_uri(), content_type='application/json', data=json.dumps({
            'name': 'Test Forum',
            'members': [ur.get_resource_uri(user)],
            'moderators': [ur.get_resource_uri(user)],
        }))
        self.assertEqual(resp.status_code, 201, resp.content)
        data = json.loads(resp.content.decode('utf-8'))
        self.assertEqual(len(data['moderators']), 1)
        self.assertEqual(len(data['members']), 1)
Ejemplo n.º 3
0
 def test_same_object_added(self):
     """
     From Issue #1035
     """
     
     user=User.objects.create(username='******')
     
     ur=UserResource()
     fr=ForumResource()
     
     resp = self.client.post(fr.get_resource_uri(), content_type='application/json', data=json.dumps({
         'name': 'Test Forum',
         'members': [ur.get_resource_uri(user)],
         'moderators': [ur.get_resource_uri(user)],
     }))
     self.assertEqual(resp.status_code, 201, resp.content)
     data = json.loads(resp.content.decode('utf-8'))
     self.assertEqual(len(data['moderators']), 1)
     self.assertEqual(len(data['members']), 1)
from tastypie.api import Api

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)