Пример #1
0
def test_conflict_on_conflicting_rows(A, B2):
    """Returns the two sets of two rows that are in conflict"""
    result = h.conflict(A, B2, [0])
    expected = pd.DataFrame(
        [
            (0, 0, "left"),
            (2, 4, "left"),
            (0, 99, "right"),
            (2, 99, "right"),
        ],
        index=[0, 2, 0, 1],
        columns=[0, 1, "_merge"],
    )
    assert result.equals(expected)
Пример #2
0
# print(ksads.shape, added.shape, deleted.shape, modified.shape)

# %%
import changes.accepted
df = ksads.set_index('id')
changes.accepted.execute(df)   # ACTION!
ksads = df.reset_index()

# %% [markdown]
# # Capture Changes

# %%
# print new shapes
added = h.diff(ksads, current_redcap.id)
deleted = h.diff(current_redcap, ksads.id)
modified = h.conflict(current_redcap, ksads, intersect_on="id", sources=("redcap", "ksads.net"))

print(ksads.shape, added.shape, deleted.shape, modified.shape)

# %%
# deleted is always empty, if not throw error
assert deleted.empty, "KSADS.net data has been deleted, take a look at `deleted` dataframe and figure out whether to delete those rows from redcap, Invalidate, mark a flag, or notify users etc."
deleted


file = open("changes/to_review.py", "w")
file.write("from changes.utils import block, modify\n\n\ndef execute(df):\n    pass\n")
# %%
def generate_blocking_code_for_added_rows(added):
    for _, row in added.iterrows():
        info = row.additionalinfo
Пример #3
0
def test_conflict_on_nonconflicting_rows(A, B):
    """Since there is no conflict, should be empty"""
    result = h.conflict(A, B, [0])
    assert result.empty