Improve randomisation of answers
This commit is contained in:
@@ -127,6 +127,19 @@ class TestResolveShuffleSeed(unittest.TestCase):
|
||||
self.assertNotEqual(first, second)
|
||||
|
||||
|
||||
class TestBuildEpochForRebuild(unittest.TestCase):
|
||||
"""Multiple-choice rebuilds must look newer to Anki by default."""
|
||||
|
||||
def test_default_uses_current_time(self):
|
||||
with patch("amateurfunk_anki.time.time", return_value=1777777777.9):
|
||||
self.assertEqual(aa.build_epoch_for_rebuild(), 1777777777)
|
||||
|
||||
def test_explicit_epoch_is_preserved_for_reproducible_builds(self):
|
||||
with patch("amateurfunk_anki.time.time") as current_time:
|
||||
self.assertEqual(aa.build_epoch_for_rebuild(1234567890), 1234567890)
|
||||
current_time.assert_not_called()
|
||||
|
||||
|
||||
class TestAnkiBuild(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
@@ -662,6 +675,42 @@ class TestAnkiBuild(unittest.TestCase):
|
||||
]
|
||||
self.assertFalse(all(byte_equal))
|
||||
|
||||
def test_cli_default_rebuild_stamps_notes_as_newer(self):
|
||||
out_a = self.root / "anki-current-a"
|
||||
out_b = self.root / "anki-current-b"
|
||||
common = [
|
||||
"--data", str(self.data_dir),
|
||||
"--explanations", str(self.explanations_path),
|
||||
]
|
||||
|
||||
with (
|
||||
patch(
|
||||
"amateurfunk_anki.resolve_shuffle_seed",
|
||||
side_effect=["fresh-a", "fresh-b"],
|
||||
),
|
||||
patch(
|
||||
"amateurfunk_anki.time.time",
|
||||
side_effect=[1777777777.9, 1777777788.1],
|
||||
),
|
||||
):
|
||||
aa.main([*common, "--out", str(out_a)])
|
||||
aa.main([*common, "--out", str(out_b)])
|
||||
|
||||
def note_mods(out_dir):
|
||||
apkg = out_dir / "amateurfunk-technische-kenntnisse-n.apkg"
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db_path, _media, _names = extract_collection(apkg, Path(tmp))
|
||||
conn = sqlite3.connect(db_path)
|
||||
try:
|
||||
return {
|
||||
row[0] for row in conn.execute("select mod from notes")
|
||||
}
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
self.assertEqual(note_mods(out_a), {1777777777})
|
||||
self.assertEqual(note_mods(out_b), {1777777788})
|
||||
|
||||
|
||||
class TestIntrinsicSvgSize(unittest.TestCase):
|
||||
"""Parsing of native figure dimensions — SVG only."""
|
||||
|
||||
Reference in New Issue
Block a user