Skip to content

Commit

Permalink
fix: use remote id for sync (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff authored Dec 13, 2023
2 parents a96cd2a + a33c680 commit b3e98f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def _delete_prompts(
self, prompts: Sequence[DestinationPrompt]
) -> None:
prompt_ids = {
int(remote_prompt.prompt.uid) for remote_prompt in prompts
int(remote_prompt.destination_id)
for remote_prompt in prompts
}
self.gateway.delete_notes(list(prompt_ids))

Expand Down
25 changes: 19 additions & 6 deletions personal_mnemonic_medium/v2/test_sync_deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@
reason="Tests require a running AnkiConnect server",
)
def test_sync_deck(tmp_path: Path):
with (tmp_path / "test.md").open("w") as f:
output_path = tmp_path / "test.md"
with output_path.open("w") as f:
f.write(
"""# Test note
Q. Test question?
A. Test answer!
"""
)

base_deck = "Tests::Integration Test deck"
apkg_output_dir = Path("/output")
read_dir = Path("/Users/Leisure/ankidecks")

sync_deck(
base_deck=base_deck,
input_dir=tmp_path,
apkg_output_dir=apkg_output_dir,
ankiconnect_read_apkg_from_dir=read_dir,
max_deletions_per_run=1,
)

# Delete the notes again
output_path.unlink()
sync_deck(
base_deck="Tests::Integration Test deck",
base_deck=base_deck,
input_dir=tmp_path,
apkg_output_dir=Path("/output"),
ankiconnect_read_apkg_from_dir=Path(
"/Users/Leisure/ankidecks"
),
apkg_output_dir=apkg_output_dir,
ankiconnect_read_apkg_from_dir=read_dir,
max_deletions_per_run=1,
)

0 comments on commit b3e98f5

Please sign in to comment.