@@ -62,3 +62,20 @@ class CatalogueTests(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'output path collides'):
|
||||
generate_practice_scores(source, output)
|
||||
self.assertFalse(output.exists())
|
||||
def test_runtime_id_collisions_preserve_existing_output(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
source, output = Path(temporary) / 'source', Path(temporary) / 'output'
|
||||
names = ('chord/one-two/three.xml', 'chord/one/two-three.xml')
|
||||
for name in names:
|
||||
path = source / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(xml_score(xml_note()), encoding='utf-8')
|
||||
output.mkdir()
|
||||
sentinel = output / 'existing.json'
|
||||
sentinel.write_text('unchanged', encoding='utf-8')
|
||||
with self.assertRaisesRegex(ValueError, 'practice exercise ID collision') as error:
|
||||
generate_practice_scores(source, output)
|
||||
for name in names:
|
||||
self.assertIn(name, str(error.exception))
|
||||
self.assertEqual(list(output.iterdir()), [sentinel])
|
||||
self.assertEqual(sentinel.read_text(), 'unchanged')
|
||||
|
||||
Reference in New Issue
Block a user