def test_kind(db_conn, posts_table): """ Expect a proposal to have a kind. """ proposal = Proposal( {"user_id": "A", "topic_id": "B", "body": "C", "entity_version": {"id": "D", "kind": "unit"}, "name": "E"} ) del proposal["kind"] proposal, errors = proposal.save(db_conn) assert len(errors) == 1 proposal["kind"] = "proposal" proposal, errors = proposal.save(db_conn) assert len(errors) == 0
def test_kind(db_conn, posts_table): """ Expect a proposal to have a kind. """ proposal = Proposal({ 'user_id': 'A', 'topic_id': 'B', 'body': 'C', 'entity_version': { 'id': 'D', 'kind': 'unit' }, 'name': 'E', }) del proposal['kind'] proposal, errors = proposal.save() assert len(errors) == 1 proposal['kind'] = 'proposal' proposal, errors = proposal.save() assert len(errors) == 0
def extract_ocr_data(): doc = [] if not request.data: response = {"response": {"status": 400, "error": "ValidationError", "message": "no request content found"}} else: content = request.get_json(silent=True) if "path" not in content: response = {"response": { "status": 400, "error": "ValidationError", "message": "path is required" }} elif "name" not in content: response = {"response": { "status": 400, "error": "ValidationError", "message": "name is required" }} else: file_path = content["path"] file_name = content["name"] doc = run_ocr(file_path) proposal_obj = make_proposal_obj(doc) print(len(doc)) proposal = Proposal(doc ,file_name, proposal_obj) proposal_id = proposal.save() response = {"response": { "status": 200, "data": proposal_obj }} print("Done!") return json.dumps(response)