From 59c22cf2a22ad1cc3661a0a0882b3b1594ba50d1 Mon Sep 17 00:00:00 2001 From: sandra0521 <39565761+sandra0521@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:49:54 +0100 Subject: [PATCH] STCC-134 Replace conversion error with warning and adapt testcases (#118) --- config/default.ini | 2 +- src/scratchtocatrobat/converter/converter.py | 4 ++-- src/scratchtocatrobat/converter/test_converter.py | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/default.ini b/config/default.ini index 2495b3fb..f3966f4a 100755 --- a/config/default.ini +++ b/config/default.ini @@ -4,7 +4,7 @@ name: Scratch2Catrobat Converter short_name: S2CC version: 0.10.0 build_name: Aegean cat -build_number: 980 +build_number: 984 ;------------------------------------------------------------------------------- [CATROBAT] diff --git a/src/scratchtocatrobat/converter/converter.py b/src/scratchtocatrobat/converter/converter.py index a236863b..17617aae 100644 --- a/src/scratchtocatrobat/converter/converter.py +++ b/src/scratchtocatrobat/converter/converter.py @@ -1991,7 +1991,7 @@ def _convert_sound_block(self): [sound_name], sound_list = self.arguments, self.sprite.getSoundList() sound_data = {sound_info.getName(): sound_info for sound_info in sound_list}.get(sound_name) if not sound_data: - raise ConversionError("Sprite does not contain sound with name={}".format(sound_name)) + log.warning("Sprite does not contain sound with name={}".format(sound_name)) play_sound_brick = self.CatrobatClass() play_sound_brick.setSound(sound_data) return play_sound_brick @@ -2001,7 +2001,7 @@ def _convert_sound_and_wait_block(self): [sound_name], sound_list = self.arguments, self.sprite.getSoundList() sound_data = {sound_info.getName(): sound_info for sound_info in sound_list}.get(sound_name) if not sound_data: - raise ConversionError("Sprite does not contain sound with name={}".format(sound_name)) + log.warning("Sprite does not contain sound with name={}".format(sound_name)) play_sound_and_wait_brick = self.CatrobatClass() play_sound_and_wait_brick.setSound(sound_data) return play_sound_and_wait_brick diff --git a/src/scratchtocatrobat/converter/test_converter.py b/src/scratchtocatrobat/converter/test_converter.py index fe4f08ab..30d87365 100644 --- a/src/scratchtocatrobat/converter/test_converter.py +++ b/src/scratchtocatrobat/converter/test_converter.py @@ -1011,11 +1011,12 @@ def test_can_convert_waitelapsedfrom_block(self): assert formula_tree_seconds.value == "1" # playSound: - def test_fail_convert_playsound_block_if_sound_missing(self): + def test_can_convert_playsound_block_if_sound_missing(self): scratch_block = ["playSound:", "bird"] bricks = self.block_converter._catrobat_bricks_from(scratch_block, DUMMY_CATR_SPRITE) assert len(bricks) == 1 - assert isinstance(bricks[0], catbricks.NoteBrick) + assert isinstance(bricks[0], catbricks.PlaySoundBrick) + assert bricks[0].sound is None # playSound: def test_can_convert_playsound_block(self): @@ -1026,11 +1027,12 @@ def test_can_convert_playsound_block(self): assert catr_brick.sound.getName() == expected_sound_name # doPlaySoundAndWait - def test_fail_convert_doplaysoundandwait_block(self): + def test_can_convert_playsoundandwait_block_if_sound_missing(self): scratch_block = ["doPlaySoundAndWait", "bird"] bricks = self.block_converter._catrobat_bricks_from(scratch_block, DUMMY_CATR_SPRITE) assert len(bricks) == 1 - assert isinstance(bricks[0], catbricks.NoteBrick) + assert isinstance(bricks[0], catbricks.PlaySoundAndWaitBrick) + assert bricks[0].sound is None # doPlaySoundAndWait def test_can_convert_doplaysoundandwait_block(self):