Skip to content

Commit

Permalink
STCC-134 Replace conversion error with warning and adapt testcases (#118
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sandra0521 authored and AntiDog committed Mar 25, 2019
1 parent 4c8587b commit 59c22cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/scratchtocatrobat/converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/scratchtocatrobat/converter/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 59c22cf

Please # to comment.