示例#1
0
class DataImportErrorTestCase(ShotgunTestCase):
    def setUp(self):
        super(DataImportErrorTestCase, self).setUp()
        self.error = DataImportError(event_data=event, source="shotgun")
        self.error.save()
        self.error_id = self.error.id

    def test_list_event_errors(self):
        errors = self.get("/import/shotgun/errors")
        self.assertEqual(len(errors), 1)
        self.assertDictEqual(errors[0], self.error.serialize())

    def test_create_event_error(self):
        self.post("/import/shotgun/errors", event)
        errors = self.get("/import/shotgun/errors")
        self.assertEqual(len(errors), 2)
        self.error = DataImportError.get(self.error_id)
        self.assertEqual(errors[1]["source"], "shotgun")
        self.assertEqual(errors[1]["event_data"]["project"]["name"],
                         event["project"]["name"])

    def test_delete_event_error(self):
        errors = self.delete("/import/shotgun/errors/%s" % self.error.id)
        errors = self.get("/import/shotgun/errors")
        self.assertEqual(len(errors), 0)

    def test_delete_event_error_wrong_id_format(self):
        errors = self.delete("/import/shotgun/errors/unknown", 404)
        errors = self.get("/import/shotgun/errors")
        self.assertEqual(len(errors), 1)

    def test_delete_event_error_404(self):
        errors = self.delete("/import/shotgun/errors/%s" % uuid.uuid4(), 404)
        errors = self.get("/import/shotgun/errors")
        self.assertEqual(len(errors), 1)
示例#2
0
 def post(self):
     error = DataImportError(event_data=request.json, source="shotgun")
     error.save()
     return error.serialize(), 201