Exemple #1
0
 def test_export_view_permission_failure(self):
     request = make_request(user=self.unprivileged_user)
     begin_ctx = begin_export(request, self.instance, 'tree')
     check_ctx = check_export(request, self.instance, begin_ctx['job_id'])
     self.assertEqual(check_ctx['status'], 'MODEL_PERMISSION_ERROR')
     self.assertEqual(check_ctx['message'],
                      'User has no permissions on this model')
Exemple #2
0
 def test_export_view_permission_failure(self):
     request = make_request(user=self.unprivileged_user)
     begin_ctx = begin_export(request, self.instance, 'tree')
     check_ctx = check_export(request, self.instance, begin_ctx['job_id'])
     self.assertEqual(check_ctx['status'], 'MODEL_PERMISSION_ERROR')
     self.assertEqual(check_ctx['message'],
                      'User has no permissions on this model')
Exemple #3
0
    def assertPsuedoAsyncTaskWorks(self, model, user, assertion_field, assertion_value, assertion_filename):

        request = make_request(user=user)
        ctx = begin_export(request, self.instance, model)
        self.assertIn("job_id", ctx.keys())
        self.assertEqual(ctx["start_status"], "OK")

        job_id = ctx["job_id"]
        job = ExportJob.objects.get(pk=job_id)
        self.assertCSVRowValue(job.outfile, 1, {assertion_field: assertion_value})

        ctx = check_export(request, self.instance, job_id)
        self.assertIn(".csv", ctx["url"])
        self.assertEqual(ctx["status"], "COMPLETE")

        self.assertRegexpMatches(job.outfile.name, assertion_filename)
Exemple #4
0
    def assertPsuedoAsyncTaskWorks(self, model, user, assertion_field,
                                   assertion_value, assertion_filename):

        request = make_request(user=user)
        ctx = begin_export(request, self.instance, model)
        self.assertIn('job_id', ctx.keys())
        self.assertEqual(ctx['start_status'], 'OK')

        job_id = ctx['job_id']
        job = ExportJob.objects.get(pk=job_id)
        self.assertCSVRowValue(job.outfile, 1,
                               {assertion_field: assertion_value})

        ctx = check_export(request, self.instance, job_id)
        self.assertIn('.csv', ctx['url'])
        self.assertEqual(ctx['status'], 'COMPLETE')

        self.assertRegexpMatches(job.outfile.name, assertion_filename)
Exemple #5
0
    def assertPsuedoAsyncTaskWorks(self, model,
                                   user,
                                   assertion_field, assertion_value,
                                   assertion_filename):

        request = make_request(user=user)
        ctx = begin_export(request, self.instance, model)
        self.assertIn('job_id', ctx.keys())
        self.assertEqual(ctx['start_status'], 'OK')

        job_id = ctx['job_id']
        job = ExportJob.objects.get(pk=job_id)
        self.assertCSVRowValue(job.outfile, 1,
                               {assertion_field: assertion_value})

        ctx = check_export(request, self.instance, job_id)
        self.assertIn('.csv', ctx['url'])
        self.assertEqual(ctx['status'], 'COMPLETE')

        self.assertRegexpMatches(job.outfile.name, assertion_filename)
Exemple #6
0
 def test_export_view_permission_failure(self):
     request = make_request(user=self.unprivileged_user)
     begin_ctx = begin_export(request, self.instance, "tree")
     check_ctx = check_export(request, self.instance, begin_ctx["job_id"])
     self.assertEqual(check_ctx["status"], "MODEL_PERMISSION_ERROR")
     self.assertEqual(check_ctx["message"], "User has no permissions on this model")