def test_literature_ui_schema_hides_emails_from_author_list(): authors = [ { "full_name": "Frank Castle", "emails": ["*****@*****.**"] }, { "full_name": "Smith, John" }, ] expected = [ { "full_name": "Frank Castle" }, { "full_name": "Smith, John" }, ] data = {"authors": authors} data_record = faker.record("lit", data=data) data_record_json = json.dumps(data_record) data = {"metadata": {"_ui_display": data_record_json}} result = LiteratureListWrappedSchema().dump(data).data assert expected == result["metadata"]["authors"]
def test_literature_ui_schema_missing_ui_display_field(): data_record = faker.record("lit") data_record_json = json.dumps(data_record) data = {"metadata": {"NOT_A_UI_DISPLAY_FIELD": data_record_json}} expected_result = {"metadata": {}} result = LiteratureListWrappedSchema().dump(data).data assert expected_result == result
def test_literature_ui_schema(): data_record = faker.record("lit") data_record_json = json.dumps(data_record) data = {"metadata": {"_ui_display": data_record_json}} expected_result = {"metadata": data_record} result = LiteratureListWrappedSchema().dump(data).data assert expected_result == result
def test_literature_ui_schema_hides_acquisition_source(mock_is_assign_request): acquisition_source = {"email": "*****@*****.**", "method": "oai", "source": "arxiv"} data = {"acquisition_source": acquisition_source} data_record = faker.record("lit", data=data) data_record_json = orjson.dumps(data_record) data = {"metadata": {"_ui_display": data_record_json}} result = LiteratureListWrappedSchema().dump(data).data assert "acquisition_source" not in result
def test_literature_ui_schema_hides_email_from_acquisition_source(): acquisition_source = { "email": "*****@*****.**", "method": "oai", "source": "arxiv" } expected = {"method": "oai", "source": "arxiv"} data = {"acquisition_source": acquisition_source} data_record = faker.record("lit", data=data) data_record_json = json.dumps(data_record) data = {"metadata": {"_ui_display": data_record_json}} result = LiteratureListWrappedSchema().dump(data).data assert expected == result["metadata"]["acquisition_source"]
def test_literature_ui_schema_with_invalid_ui_display(): data = {"metadata": {"_ui_display": "foo"}} expected_result = {"metadata": {}} result = LiteratureListWrappedSchema().dump(data).data assert expected_result == result