Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions redcap/methods/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def delete_records(

Args:
records: List of record IDs to delete from the project
return_format_type:
Response format. By default, response will be json-decoded.

Returns:
Union[int, str]: Number of records deleted
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/test_simple_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# pylint: disable=missing-function-docstring
import os

from io import StringIO

import pandas as pd
import pytest
import semantic_version
Expand Down Expand Up @@ -57,6 +59,32 @@ def test_import_and_delete_records(simple_project):
assert res == 3


@pytest.mark.integration
@pytest.mark.parametrize(
["return_format_type", "import_output", "delete_output"],
[
("csv", "3", "3"),
("xml", '<?xml version="1.0" encoding="UTF-8" ?><count>3</count>', "3"),
],
)
def test_import_and_delete_records_non_json(
simple_project, return_format_type, import_output, delete_output
):
new_record_ids = ["4", "5", "6"]
test_records_csv = "record_id\n" + "\n".join(new_record_ids)
test_records_df = pd.read_csv(StringIO(test_records_csv))

res = simple_project.import_records(
test_records_df, import_format="df", return_format_type=return_format_type
)
assert res == import_output

res = simple_project.delete_records(
new_record_ids, return_format_type=return_format_type
)
assert res == delete_output


@pytest.mark.integration
def test_import_df_no_index(simple_project):
# declare df_kwargs without specifying index, which returns a df with no index
Expand Down