Exemplo n.º 1
0
    def test_rest_service(self):
        """
        Test rest service creating and deletion for a merged dataset.
        """
        count = RestService.objects.count()
        merged_dataset = self._create_merged_dataset()
        xform = XForm.objects.get(pk=merged_dataset['id'])
        view = RestServicesViewSet.as_view({'post': 'create'})

        post_data = {
            "name": "generic_json",
            "service_url": "http://crunch.goodbot.ai",
            "xform": xform.pk
        }
        request = self.factory.post('/', data=post_data, **self.extra)
        response = view(request)

        self.assertEquals(response.status_code, 201)
        self.assertEquals(count + 3, RestService.objects.count())

        # deleting the service for a merged xform deletes the same service from
        # the individual forms as well.
        service = RestService.objects.get(xform=xform)
        service.delete()
        self.assertEquals(count, RestService.objects.count())
    def test_rest_service(self):
        """
        Test rest service creating and deletion for a merged dataset.
        """
        count = RestService.objects.count()
        merged_dataset = self._create_merged_dataset()
        xform = XForm.objects.get(pk=merged_dataset['id'])
        view = RestServicesViewSet.as_view({'post': 'create'})

        post_data = {
            "name": "generic_json",
            "service_url": "http://crunch.goodbot.ai",
            "xform": xform.pk
        }
        request = self.factory.post('/', data=post_data, **self.extra)
        response = view(request)

        self.assertEquals(response.status_code, 201)
        self.assertEquals(count + 3, RestService.objects.count())

        # deleting the service for a merged xform deletes the same service from
        # the individual forms as well.
        service = RestService.objects.get(xform=xform)
        service.delete()
        self.assertEquals(count, RestService.objects.count())
 def setUp(self):
     super(TestRestServicesViewSet, self).setUp()
     self.view = RestServicesViewSet.as_view({
         'delete': 'destroy',
         'get': 'retrieve',
         'post': 'create',
         'put': 'update'
     })
     self._publish_xls_form_to_project()
Exemplo n.º 4
0
 def setUp(self):
     super(TestRestServicesViewSet, self).setUp()
     self.view = RestServicesViewSet.as_view({
         'delete': 'destroy',
         'get': 'retrieve',
         'post': 'create',
         'put': 'update'
     })
     self._publish_xls_form_to_project()