Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deck and note options. #12

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update tests to create OptionGroups.
  • Loading branch information
holocronweaver committed Aug 24, 2017
commit 4d0449a205204432e234339ad4a06a993ada60f5
12 changes: 8 additions & 4 deletions tests/test_genanki.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def import_package(self, pkg):
importer.run()

def test_generated_deck_can_be_imported(self):
deck = genanki.Deck(123456, 'foodeck')
options = genanki.OptionsGroup(654321, 'foooptions')
deck = genanki.Deck(123456, 'foodeck', options)
note = genanki.Note(TEST_MODEL, ['a', 'b'])
deck.add_note(note)

Expand All @@ -121,7 +122,8 @@ def test_generated_deck_has_valid_cards(self):

Catches a bug that was fixed in 08d8a139.
"""
deck = genanki.Deck(123456, 'foodeck')
options = genanki.OptionsGroup(654321, 'foooptions')
deck = genanki.Deck(123456, 'foodeck', options)
deck.add_note(genanki.Note(TEST_CN_MODEL, ['a', 'b', 'c'])) # 2 cards
deck.add_note(genanki.Note(TEST_CN_MODEL, ['d', 'e', 'f'])) # 2 cards
deck.add_note(genanki.Note(TEST_CN_MODEL, ['g', 'h', 'i'])) # 2 cards
Expand All @@ -135,7 +137,8 @@ def test_generated_deck_has_valid_cards(self):

def test_card_isEmpty__with_2_fields__succeeds(self):
"""Tests for a bug in an early version of genanki where notes with <4 fields were not supported."""
deck = genanki.Deck(123456, 'foodeck')
options = genanki.OptionsGroup(654321, 'foooptions')
deck = genanki.Deck(123456, 'foodeck', options)
note = genanki.Note(TEST_MODEL, ['a', 'b'])
deck.add_note(note)

Expand Down Expand Up @@ -192,7 +195,8 @@ def test_media_files(self):
# change to a scratch directory so we can write files
os.chdir(tempfile.mkdtemp())

deck = genanki.Deck(123456, 'foodeck')
options = genanki.OptionsGroup(654321, 'foooptions')
deck = genanki.Deck(123456, 'foodeck', options)
note = genanki.Note(TEST_MODEL, [
'question [sound:present.mp3] [sound:missing.mp3]',
'answer <img src="present.jpg"> <img src="missing.jpg">'])
Expand Down