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)
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_create_event_error(self): self.post("data/import/shotgun/errors", event) errors = self.get("data/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 delete(self, error_id): try: error = DataImportError.get(error_id) except StatementError: abort(404) if error is None: abort(404) error.delete() return {"deletion_success": True}, 204
def post(self): error = DataImportError(event_data=request.json, source="shotgun") error.save() return error.serialize(), 201
def get(self): criterions = {"source": "shotgun"} import_errors = DataImportError.query.filter_by(**criterions).all() return DataImportError.serialize_list(import_errors)